Skip to content

Instantly share code, notes, and snippets.

@onkar-singh
Created July 22, 2018 10:45
Show Gist options
  • Save onkar-singh/7a1843824cd230f9af9bc5d7c726f713 to your computer and use it in GitHub Desktop.
Save onkar-singh/7a1843824cd230f9af9bc5d7c726f713 to your computer and use it in GitHub Desktop.
JS Selectors
var X = document.getElementById("intro");
var x = document.getElementsByTagName("p");
var x = document.getElementsByClassName("intro");
var x = document.querySelectorAll("p.intro");
element.innerHTML = new html content // Exam:- object.innerHTML/.innerText/.textContent = "<p>Dog</p>";
element.attribute = new value // Exam:- object.src = "landscape.jpg";
element.style.property=newstyle // Exam:- object.style.color="blue";
element.setAttribute(attribute, value) // Exam:- object.setAttribute("style", "background-color: red;");
element.removeAttribute(attributename) // Exam:- object.removeAttribute("href");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment