Category : element

The ‘X’ is unable to display "none" to the UL element. Is there a problem with the getElement? or should I use query selector. function clear() { var hide = document.getElementById(“myUL1”); hide.style.display = “none”; } span { cursor: pointer; } <div> <ul id=”myUL1″> <li>list</li> <li>HTML</li> <li>CSS</li> <li>JavaScript</li> </ul> <div>Clear list <span onclick=”clear()”>X</span></div> </div> Source: Ask ..

Read more

How to get another html file as if getting it by document Basically, the same ‘document’ instance type used for document.getElementsByClassName(), but instead of getting the document the javascript code is in, it gets another .html file in the same domain. For example, "blog.html". Here’s what I want it to hypothetically look like var blogdocument ..

Read more

I’m creating a profiles page in javascript/jquery and I’m using a carousel of div’s to accomplish said task. The question I have is, how do I programmatically access each style.display or $("#username").hide() or .show() ? …. <div class="profiles"> 1 / 3 <img src="images/blank1.jpg" style="width:90%"> </div> <div class="profiles"> 2 / 3 <img src="images/blank2.jpg" style="width:90%"> </div> <div ..

Read more

I have some confusion over the .parentNode syntax within my code. I reviewed mozilla.org’s reference guide which indicates "parentNode is the parent of the current node. The parent of an element is an Element node, a Document node, or a DocumentFragment node." That sounds very black and white but when looking at my code it ..

Read more

I would like to make the <li> element to change the class when I click on it, and when I click one more time to remove it. I have used simple code like this : var ul = document.querySelector("ul"); ul.addEventListener("click", function() { var li = document.querySelector("li"); li.classList.add("done"); }) ul.addEventListener("dblclick", function() { var li = document.querySelector("li"); ..

Read more