javascript - Getting values from child nodes in an element -



javascript - Getting values from child nodes in an element -

what want can done in 3 steps: 1. find specific element 2. find specific kid nodes in element 3. extract values particular kid nodes know, it's simple, i'm new javascript. let's consider next code, comments help out.

<!--we're going @ content of "p" tag--> <p id="demo"> <!--here have textbox , drop downwards list--> <input type="text" value="a value"/> <select> <option value="zero">0</option> <option value="1">1</option> </select> </p> <!--this button finds "p" element id of "demo", looks @ kid nodes.--> <input type="button" onclick="extractv()" value="get values"/> <script> function extractv() { document.getelementbyid("demo").//this bit don't know. } </script>

there go. can't find right tag find specific node in tag (or matter) , extract values know there's way. if know great. help aid endeavors appreciated. constructive criticism don't mind. give thanks you!

p.s: don't think come stack overflow inquire dumb questions. i've consulted books , other people. lastly resort. if have question question please ask.

i'm not sure, think want http://jsfiddle.net/kzwt9/

<!--we're going @ content of "p" tag--> <p id="demo"> <!--here have textbox , drop downwards list--> <input type="text" value="a value"/> <select> <option value="zero">0</option> <option value="1">1</option> </select> </p> <!--this button finds "p" element id of "demo", looks @ kid nodes.--> <input id="extractv" type="button" value="get values"/> <script> function extractv() { els = document.getelementbyid("demo").childnodes; (var = 0; < els.length; ++i) { console.log( els[i].value ); } } document.getelementbyid("extractv").addeventlistener('click',extractv, false); </script>

javascript extract

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -