开发者

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 you


Taking @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());
 });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜