I have the following code.
<div class="container">
<input type="hidden" name="id" value="123" class="id" />
<div class="inner">
<a href="#" class="link">link</a>
</div>
</div>
So I am trying to get the hidden id value when the anchor tag is clicked. And this is the following code I tried but didn’t work.
jQuery("a.link").click(function() {
var id = jQuery(this).parents(".container").children("input.id").val();
alert(id);
});
Not even sure if that is the best way to select what I want…Some guidance would be appreciated.
try