0

my code is

<ul id="start">
  <li>
    <input type="hidden" value="abc" >
  </li>
</ul>

I don't id of Ii and Input Type I want value of input type in javascript

in css we use

#start li input{
//code 
}

how to do same thing in javascript

3 Answers 3

3

Using querySelector:

var value = document.querySelector("#start li input").value

Or if you can't use that:

var value = document.getElementById("start").getElementsByTagName("input")[0].value;
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:-

 document.querySelector("#start li input").value;

Comments

0

You can directly access the first element with

document.getElementById('start').children[0].children[0]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.