+ 6

How to change element by tag name in Java script

i have tried this but it doesnt work? https://code.sololearn.com/WJDmE8jZHtAj/?ref=app

8th Sep 2018, 10:33 AM
David Agustinus
David Agustinus - avatar
4 Answers
+ 8
You can see here the corrections. https://code.sololearn.com/WHahM45r1ZL3/?ref=app
8th Sep 2018, 10:48 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 3
Use window.addEventListener('DOMContentLoaded,loadP); function loadP(){ ....Use your code here... } perhaps the script file was included in the head section in the html so the script was called even before the Dom was loaded,so it was unable to change the content of p
8th Sep 2018, 7:45 PM
Mithilesh
Mithilesh - avatar
+ 2
The Element.getElementsByTagName() method returns a live HTMLCollection of elements with the given tag name. The subtree underneath the specified element is searched, excluding the element itself. The returned list is live, meaning that it updates itself with the DOM tree automatically. Consequently, there is no need to call several times Element.getElementsByTagName() with the same element and arguments. When called on an HTML element in an HTML document, getElementsByTagName puts its argument in lower case before proceeding. This is undesirable when trying to match camel-cased SVG elements in a sub-tree in an HTML document. Element.getElementsByTagNameNS() works in that case. Element.getElementsByTagName is similar to Document.getElementsByTagName(), except that its search is restricted to those elements which are descendants of the specified element. Link to sectionSyntax elements = element.getElementsByTagName(tagName) elements is a live HTMLCollection of found elements in the order they appear in the sub-tree. If no elements were found, the HTMLCollection is empty. element is the element from where the search should start. Note that only the descendants of this element are included in the search, but not the element itself. tagName is the qualified name to look for. The special string "*" represents all elements. For compatibility with XHTML, lower-case should be used. Also Read:https://crbtech.in/Java-Training/significant-things-you-need-to-know-about-java-9significant-things-you-need-to-know-about-java-9/
10th Sep 2018, 6:18 AM
kiran sahu
kiran sahu - avatar
0
querySelector is the same CSS selector. You'll might choose all types: "#id", ".class", "tag" and more "tag1 tag2 .class". document.querySelector("p").innerHTML = "Something";
19th Sep 2018, 9:18 AM
Mr Genesis
Mr Genesis - avatar