Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
129
rated 0 times [  133] [ 4]  / answers: 1 / hits: 26874  / 11 Years ago, fri, november 1, 2013, 12:00:00

i have some html code like this



<form name=first><input name=firstText type=text value=General /> 
<input name=secondText type=text value=General />
<input name=ThirdText type=text value=General />
<input name=FourthText type=text value=General />
<input name=FifthText type=text value=General />
</form>

<form name=second><input name=firstText type=text value=General />
<input name=secondText type=text value=General />
<input name=ThirdText type=text value=General />
<input name=FourthText type=text value=General />
<input name=FifthText type=text value=General />
</form>


i want to select secondText of form second using jquery or javascript and i want to change value of it using jquery.


More From » jquery

 Answers
6

Using jQuery:



var element = $(form[name='second'] input[name='secondText']);


Using vanilla JS:



var element = document.querySelector(form[name='second'] input[name='secondText']);


Changing the value: element.val(value) or element.value = value, depending of what you are using.


[#74562] Thursday, October 31, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myakylas

Total Points: 66
Total Questions: 85
Total Answers: 95

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
myakylas questions
Thu, Apr 28, 22, 00:00, 2 Years ago
Thu, Apr 8, 21, 00:00, 3 Years ago
Sat, Sep 19, 20, 00:00, 4 Years ago
;