I have event mouseenter
link with get ajax request, I want to get selector $(this)
of link and get attribute. I\'m use context
of setting
try assigning "this" to a variable:
jQuery(document).ready(function($) {
var request;
$('a[rel="bookmark"]').mouseenter(function() {
var that=this;
// other stuff
request = $.ajax({
dataType: "JSON",
url: '',
data: {"action": "our_ajax_function", "id": dataId},
success: function(data){
// other stuff
var gettitle = $(that).data('title','Permanent Link to ');
}
})
});
also while using the HTML5 Data Attribute you can get or modify the data in jQuery with the data()
function:
$(that).data('title','Permanent Link to '); //sets the "data-title" of the selected element as "Permanent Link to "