how can i get the value of the type=hidden when i click the <tr class='click'>?
i only get the value of first hidden and when i click the other <tr> the same value from first hidden.

jquery code

$(document).ready(function(){

  $('tr[class='click']').click(function(){
     
    var a= $('tr[class='click'] input:hidden').val();
   alert("a");
});

});

html code

<table id='tbform'>
<tr class='click'>
 <td><input type='hidden' id='txtval' value='1' name='txtval[]' ></td>
</tr>
<tr class='click'>
<td><input type='hidden' id='txtval' value='2' name='txtval[]' ></td>
</tr>
<tr class='click'>
<td><input type='hidden' id='txtval' value='3' name='txtval[]' ></td>
</tr>
</table>

You get the first hidden in your click event, because you repeat the same selector. What you can do is:

$("tr[class='click']").click(function(){
  var a = $(this).find('input:hidden').val();
  alert(a);
});

What it does is start from this (the row you clicked on), and then find the next hidden from there. Note that there is also a problem with your single quotes in the selector.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.