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