Get the label of click check box
i have a page which generate check boxes dynamically and i have the following event which fires every time a user click on any of the check boxes
$(':checkbox').click(function() {
});
My question is how can i get the text o开发者_如何学Gof the check box that has been trigger by the user?
Thank youTaking @CliffC query and changing it, This should work. Its an explicit query so you will always get the correct label
$(':checkbox').click(function() {
alert( $(this).parent().find("label[for=" + this.id +"]").text());
});
found the solution
$(':checkbox').click(function() {
alert( $(this).parent().find("label").text());
});
精彩评论