Addressing a certain DOM tree element [JQuery]
-
We have:
<html> <body> <div> <form> <ul> <li> <label>Simple text 1</label> <input type="text" name="inp1" value="Text 1"> </li> <li> <label>Simple text 2</label> <input type="text" name="inp2" value="Text 2"> </li> <li> <label>Simple text 3</label> <input type="text" name="inp3" value="Text 3"> </li> <ul> <input class="getInfoButton" type="button" value="Get Value"> </form> </div> </body> </html>
Salt: We need to get the third.
<input>
with this selter$(".getInfoButton")
We need to solve this optimum task if I want to move the third tree in DOM.
<input>
a few.<li>
(between third and second)<li>
additional items)P.S If that's not possible, then I understand it's my function.
-
Choose the identifier:
$('#id3')
(but this identifier should be added to the relevant<input id="id3">
or just choose your name.$('[name="inp3"]')
♪Or in your task:
$('.getInfoButton').prev().find('[name="inp3"]')
I just don't understand why you're the one who's trying to get away from this sector, but it's yours.