Reputation: 135
I want to assign ajax return data to button's title attribute on hover of button, so i use $('#data_btn').title = html(returndata);
, in below code, then it unable to show any output.
Here, #data_btn is id of button element.
Please help me regarding.
$('#data_btn').hover(function(){
var val_d = $('#country').val() +"-"+ $('#city').val();
window.alert(val_d);
if(val_d != 0)
{
$.ajax({
type:'post',
url:'getdata.php',
data:{id:val_d},
cache:false,
success: function(returndata){
$('#data_btn').title = html(returndata);
//$('#data_btn').html(returndata);
}
});
}
})
Upvotes: 3
Views: 9283
Reputation: 135
by trying below code, it works for me.
$('#data_btn').attr('title',returndata);
Upvotes: 3
Reputation: 7004
if you want to use $('#data_btn').title = returnData;
, do this: $('#data_btn')[0].title = returnData;
, html()
is undefined, so just assign returnData to your title
Upvotes: 3
Reputation: 905
You never use .title = html(returndata);
the = sign in a jQuery chain...
also, .title() is not a function.
Use the following:
$('#data_btn').attr('title', $(this).html(returndata));
Upvotes: 0