开发者

Get the label of click check box

开发者 https://www.devze.com 2023-01-01 21:31 出处:网络
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

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

精彩评论

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

关注公众号