Reputation: 9081
I have a javascript snippet in which I'd like to retrieve the value of a hidden input located in the first column of selected row :
var global_id = $(this).find("td:first").html();
console.log("value=" + global_id);
I get as result :
value =<input id="id" name="id" type="hidden" value="2">
When I try
var global_id = $(this).find("td:first").val();
console.log("value=" + global_id);
I get as result :
value =
So, I need to know :
Upvotes: 0
Views: 572
Reputation:
You need to reference the actual input element, not the containing element. This will find the input element if it is hidden using type="hidden"
, using css or using jQuery's hide()
var global_id = $("td:first input:hidden:first", this).val();
console.log("value=" + global_id);
Upvotes: 6