Techonthenet
Techonthenet

Reputation: 157

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 can I.

thanks in advance

Upvotes: 1

Views: 2545

Answers (3)

rahul
rahul

Reputation: 187030

You can use something like

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

See a working demo

Upvotes: 1

JohnP
JohnP

Reputation: 50019

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(','));

Upvotes: 0

Makram Saleh
Makram Saleh

Reputation: 8701

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"));
    });
});

Upvotes: 0

Related Questions