开发者

How to get text from the title attribute when <th> is clicked?

If I have the following HTML:

<th title="Title Description">Blah</th>

How do I select text from the title attribute when I click on 开发者_开发问答<th>?


$(function() {
    $('th').click(function() {
        var title = $(this).attr('title');
    });
});


$(function () {
    $('th').click(function () {
        var title = $(this).attr('title');
        // do something useful with title
    });
});


Try this

$(document).ready(function() {
        $('th').click(function() {
           var title = $(this).attr('title');
           alert(title);
      });
    });


$('th').click(function(){alert($(this).attr('title'));});


$('tr').click(function() {
    var title = $(this).children('th').attr('title');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜