JavaScript - How Do You Removeclass From Children?
Hey all,
I have a dropdown (id='job-roles'), and I would like to remove a class from all of the options in the dropdown when certain conditions are met, but I cannot figure out how to do it. Is anyone able to help please? Thanks. Similar Tutorialsmorning all, I need help with a HTML UL I have ul inside ul but all I want to get when I select a certain list is the children of that list but remove the ul inside that list so they dont show at all http://pastebin.com/m98deaff any help would be great , current selecting code is http://pastebin.com/m6f4b886f Code: <div class="demo" id="demo_1"> <ul> <li id="1" class="open"><a id="1" href="#"><ins> </ins>Root node 1</a> <ul> <li id="2"><a id="2" href="#"><ins> </ins>Child node 1</a></li> <li id="3"><a id="3" href="#"><ins> </ins>Child node 2</a></li> <li id="4"><a id="4" href="#"><ins> </ins>Some other child node with longer text</a></li> <li id="6"><a id="6" href="#"><ins> </ins>Root node 222</a> //SHOUL NOT BE IN MY ARRAY <ul> <li id="7"><a id="7" href="#"><ins> </ins>Child node 222a</a></li> <li id="8"><a id="8" href="#"><ins> </ins>Child node 222b</a></li> <li id="9"><a id="9" href="#"><ins> </ins>Some other child node with longer text 222</a></li> </ul> //END OF UL ELEMENT N OT NEEDED THERE COULD BE more than 1 </li> </ul> </li> <li id="5"><a id="5" href="#"><ins> </ins>Root node 2</a></li> </ul> </div> Hi guys I was wondering if its possible in javascript to do something like this: Code: document.getElementById('div').children('img').style This is my code with int value I can target children is this also possible with a string like img? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <script type="text/javascript"> window.onload=function() { var d = document; var e = d.getElementById('t'); e.children[0].style.border = "solid black 1px"; } </script> </head> <body> <div id="t"> <img width="120" height="80" src="./images/full6.jpg" alt="" /> <img width="120" height="80" src="./images/full6.jpg" alt="" /> <img width="120" height="80" src="./images/full6.jpg" alt="" /> <img width="120" height="80" src="./images/full6.jpg" alt="" /> </div> </body> </html> Hi guys I have a navagation like this: Code: <ul id="nav" class="menu"> <li><a href="">Link Hover</a> <ul> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> </ul> </li> <li><a href="">Link Hover</a> <ul> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> </ul> </li> <li><a href="">Link Hover</a> <ul> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> </ul> </li> <li><a href="">Link</a></li> <li><a href="">Link</a></li> <li><a href="">Link Hover</a> <ul> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> <li><a href="">hidden</a></li> </ul> </li> </ul> Im trying to use javascript to count only the direct li children of ul. So I tried childnode but im not really familiar with it. Basically the li items inside the li should not be counted. |