Created
June 25, 2020 06:22
-
-
Save aashishrbhandari/cdd178309e31da18c28bfdaefdf7368c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOM ( Document Object Modal ) | |
------------------------------- | |
The DOM represents a document with a logical tree. | |
The HTML DOM is an object-based representation of the source HTML document. | |
CSS & JS Query | |
Let's see this | |
--------------- | |
HTML: | |
----- | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>My first web page</title> | |
</head> | |
<body> | |
<div class="mainDiv"> | |
<img src="/images/1.png"> | |
<h1>Hello, world!</h1> | |
<p>How are you?</p> | |
</div> | |
</body> | |
</html> | |
JS: | |
--- | |
document.querySelector(".mainDiv img").addEventListener( 'click', function(event) { | |
console.log("Clicked on Image Inside mainDiv"); | |
}); | |
CSS: | |
---- | |
.mainDiv img { | |
height: 40%; | |
width: 40%; | |
} | |
As you can see above the same query selector is used in css and js | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment