开发者

Select input field with name as array field

开发者 https://www.devze.com 2023-02-10 06:55 出处:网络
I wanted to select the text field based on condition, for example: if only text field name = sname[] than only put value in it开发者_运维知识库.

I wanted to select the text field based on condition, for example:

if only text field name = sname[] than only put value in it开发者_运维知识库.

For this I used

<input type="text" name="sname[]" />

where name = sname;

//For each name type field in extra add contact module if that i visible.
    $('input[name=' + name + '[]]').each(function() { 

});

But I'm not able to get inside of it. Please suggest how to get into the selection.


$('input[name="' + name + '[]"]').each(function() {
    $(this).val('Some value');
});


No need for each loop, you could do it like :

$('input[name="field_name[]"]').val('Some value');

Hope this helps.

0

精彩评论

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