Reputation: 47995
I have this code :
<div class="trackon" id="<?="trackline1">
<input type="hidden" name="atloriginal[]" value="1" /></span>
</div>
<div class="trackon" id="<?="trackline2">
<input type="hidden" name="atloriginal[]" value="2" /></span>
</div>
<div class="trackon" id="<?="trackline3">
<input type="hidden" name="atloriginal[]" value="3" /></span>
</div>
How can I change the hidden value of trackline2 on "hello"? I'm here :
$('#trackline2').find("DON'T KNOW HOW TO WRITE THIS").val("hello");
is is possible to set that value to an input array?
Upvotes: 0
Views: 110
Reputation: 31260
If you have just one input
$('#trackline2 input').val("hello");
If you have more than one, you need to have some way of identifying them. May be using name...
$('#trackline2 input[name="atloriginal[]"]').val("hello");
Upvotes: 3
Reputation: 58611
Assuming the trackon
class objects are the only ones on the page, and they are always in order, you could use:
$('.trackon').eq(2).val('hello')
Upvotes: 0