KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How would you select the first input in the code below without editing the DOM (using jQuery if needed)? <input type="text"/> <!-- The element I want to select --> <script> // Select the input above </script> <input type="text"/> Please note there is an unknown number of inputs and script tags before and after this code sample, thus solutions like $("input:eq(1)") won't work. The tricky part is to select the input placed right before the script tag from which the current JavaScript is being executed. No need to ask me why I want to do this either, that's purely for the beauty of it, I want to do it without having to add random ids to my inputs if that's possible. Edit Here's why most of the answers won't work: http://jsfiddle.net/2WqfP/
Tags (comma-separated)
Save Edits
Cancel