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');
});
精彩评论