Issue
In this code, I want to get input value by javascript, How can I do? Thanks.
<div id='my-id' class='my-class'>
<div>
<input type='text'>
</div>
</div>
Solution
Easiest way is querySelector
document.querySelector("#my-id input")
Old way is getElementsByTagName
document.getElementsByTagName("input")[0];
document.getElementById("my-id").getElementsByTagName("input")[0];
If your element is in a form, you can go old school with
document.forms[0].elements[0]
Answered By - epascarello
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.