Reputation: 11466
I am trying to get the value from the name in a hidden field. The name / value is created dynamically. The ID column is created sequentially. here is the HTML
<div="campAddons">
<input type="hidden" id="column2" name="Housing" value="108">
<div>
here is my jquery
column1Name = $("#campAddons input[id='column2']").val(name);
console.log(column1Name);
i keep getting object.object in the console log.
Upvotes: 0
Views: 7789
Reputation: 67217
Name is an attribute. So you have to use .attr()
to get its value. Please read here to learn more about it.
Try,
column1Name = $("#campAddons input[id='column2']").attr('name');
console.log(column1Name);
OR
column1Name = $("#column2").attr('name');
console.log(column1Name);
Upvotes: 4