Skip to content Skip to sidebar Skip to footer

JQuery Get Value From Hidden Input In Column

I have got the following HTML table...

Solution 1:

Here's how you do it :

$(".info").click(function(e) {
  //just in case, will be useful if your href is anything other than #
  e.preventDefault();
  alert($(this).prev('input[type="hidden"]').val());
});

prev method will search for the previous element, which is where your input[hidden] is.

And its href, not hre, in the <a/> tags.


Solution 2:

You can also use attributes <a href="#" data-hidden="1" class="info"> don't need use hidden fields

$(".info").click(function(e) {
  e.preventDefault();
  alert($(this).data('hidden')); // or $(this).attr('data-hidden');
});

Post a Comment for "JQuery Get Value From Hidden Input In Column"

Nr. Name Info