Jquery Get Index Of Element
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title> </title> <script src="jquery-1.8.3.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $('.c_book').live('click',function(){ var ind = $('.c_book').index(this); var val = $('.c_book').eq(ind).val(); alert('index = '+ind+' , value = '+val); }); }); </script> </head> <body> <div> checkbox1 :: <input name="cb" class="c_book" type="checkbox" value="v1"> checkbox2 :: <input name="cb" class="c_book" type="checkbox" value="v2"> checkbox3 :: <input name="cb" class="c_book" type="checkbox" value="v3"> checkbox4 :: <input name="cb" class="c_book" type="checkbox" value="v4"> checkbox5 :: <input name="cb" class="c_book" type="checkbox" value="v5"> <div> </body> </html> |