admin管理员组文章数量:1321065
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);
}
});
}
})
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);
}
});
}
})
Share
Improve this question
edited Apr 28, 2015 at 11:04
Shaunak D
20.6k10 gold badges47 silver badges79 bronze badges
asked Apr 28, 2015 at 10:56
Vijaya SavantVijaya Savant
1354 silver badges19 bronze badges
6
-
1
$('#data_btn').attr('title', html(returndata));
– Rahul Tripathi Commented Apr 28, 2015 at 10:57 - I replaced my code with your, but not working for me. – Vijaya Savant Commented Apr 28, 2015 at 11:02
-
What does
html()
function do? Shouldn't that just be$('#data_btn').attr('title', returndata);
– Shaunak D Commented Apr 28, 2015 at 11:03 -
Are you even getting into
success:
parameter?? – Dhaval Marthak Commented Apr 28, 2015 at 11:03 - Arghhh! It's time for me to learn how to change baby nappies :) Step 1: get nappies. – lshettyl Commented Apr 28, 2015 at 11:06
3 Answers
Reset to default 3if 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
jsfiddle
by trying below code, it works for me.
$('#data_btn').attr('title',returndata);
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));
本文标签: javascripthow to set title attribute of button using jqueryStack Overflow
版权声明:本文标题:javascript - how to set title attribute of button using jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742025464a2415458.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论