开发者

jQuery - How to get a single value[]

开发者 https://www.devze.com 2023-02-25 03:01 出处:网络
I have this code : <div class=\"trackon\" id=\"<?=\"trackline1\"> <input type=\"hidden\" name=\"atloriginal[]\" value=\"1\" /></span>

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="hidde开发者_开发技巧n" 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?


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");


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')
0

精彩评论

暂无评论...
验证码 换一张
取 消