| | |
Get all children and their childeren - not innerHTML
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
•
•
I need to get all children of a DIV and their children too. I mean I need to get the HTML text of a DIV but I don't like to use innerHTML since it does not support the values of inputs in many browsers. How can I do that?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script language="JavaScript"> function test(){ var listOfChildNodes = document.getElementById('IDofTheDiv').childNodes; var numberOfChildNodes = listOfChildNodes.length; var str=""; for(i=0;i<numberOfChildNodes;i++){ str += listOfChildNodes[i].tagName+"\n";// this is the way you access childNodes ... tagName is just for example purpose. } alert(str); } </script> <div id= "IDofTheDiv"> <span></span> <p></p> <a></a> </div> <a href="javascript:test()">Click Here</a>
This is NOT what you exactly want .... but hope this would be of your help.
Regards ...
IF SOMEONE FEELS THAT THEY HAD NEVER MADE A MISTAKE IN THEIR LIFE, THEN IT MEANS THEY HAD NEVER TRIED A NEW THING IN THEIR LIFE
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: using javascript to alter css of iframe div
- Next Thread: Javascript ad rotator
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box bug calendar captcha cart codes column cookies createrange() css cursor date debugger decimal design dom download dropdown element embed enter error events firefox focus form frameworks getselection google gwt hiddenvalue hint html htmlform ie7 iframe image() index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps marquee masterpage media menu microsoft mimic mp4 onerror onmouseover paypal php player position post problem programming progressbar prototype rating redirect regex safari scale scriptlets search security select software sql starrating text textarea toggle unicode validation variables w3c webservice website window windowofwords windowsxp xml





