开发者

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

开发者 https://www.devze.com 2023-04-09 17:44 出处:网络
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() {

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

精彩评论

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