开发者

Read tooltip of checkbox of using jquery

I have table with check boxes in it.and the CSS for the check box is GridCheckBox, I want to read the check boxes tool tip into an array with , separated. How ca开发者_开发技巧n I.

thanks in advance


You can use something like

var tooltipTexts = $("#tableid input:checkbox.GridCheckBox").map(function(){
    return $(this).attr("title");
}).get().join(',');

See a working demo


Assuming that your tooltip text is in the title attribute of the checkbox, then you do the following:

var tooltips = [];

$(function(){
    $(".GridCheckBox").each(function(){
        tooltips.push($(this).attr("title"));
    });
});


You can iterate over it using .each and then use Array.join() to make it a string.

Here's a fiddle : http://jsfiddle.net/dHCZt/

var titles = [];
$('.GridCheckBox').each(function() {
    if ($(this).attr('title')) {
        titles.push($(this).attr('title'));
    }
});

console.log(titles);
console.log(titles.join(','));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜