JavaScript - DOM and Events Fundamental
JavaScript - DOM and Events Fundamental
querySelector(“”)
For Id we use:- document.querySelector(“#IdName”);
For Class we use: - document.querySelector(“.classname”);
if you want to select all the same class name code is: -
document.querrySelectorAll(“.class name”); it select all of them with same class name
example: -
Selecting and Manipulating
Changing start guessing… into “🎉 Correct Answer!”
.value
document.querrySelector(“class or ID name”).value;
Example: -
Output is
Handling Click Events
document.querrySelector(“Id or class name”).addEventListener("what do you want ( I wnt
click ), function(){
type anything
})
example: -
Output is
output is
or perfect way
Manipulating img
Toggle tag