Professional Documents
Culture Documents
JavaScript:
• The querySelector() method returns the first element that matches a CSS
selector.
To return all matches (not only the first), use the querySelectorAll() instead.
Both querySelector() and querySelectorAll() throw a SYNTAX_ERR
exception if the selector(s) is invalid.
• The addEventListener(“click”, function) method attaches an event handler
to an element without overwriting existing event handlers.
• document.getElementById("demo").innerHTML = "Hello Dolly."; —> This
statement tells the browser to write "Hello Dolly." inside an HTML element
with id="demo"— To change the content of an HTML element
• Choose a background color :
<script>
function changebody() {
document.bgColor=document.getElementById("colorid").value;}
</script>
<form>
Choose a Background Color : declares when an input is changed.