Posts

Showing posts with the label get element by id examples

querySelector() and querySelectorAll() in Dom Manipulations Methods in Javascript

Image
querySelector() and querySelectorAll()

How to change images on mouse hover using javascript | mouse hover events

Image
How to change images on mouse hover using javascript | mouse hover events <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <meta name="viewport" content="width=device-width, initial-scale=1.0">   <meta http-equiv="X-UA-Compatible" content="ie=edge">   <title>Test Page</title> </head> <body>   <img id="photo" onmouseover="box3()" onmouseout="box4()" src="1.png" width="200px" height="100px" > //remember to change source of photo <script> function box3() {   document.getElementById("photo").src="2.jpg"; //remember to change source of photo } function box4() {   document.getElementById("photo").src="1.png"; //remember to change source of photo } </script> Here is how the output looks like :

DOM in Javascript - how to get/set all ID, CLASS and TAGS (full information with working code)

Image
DOM in Javascript - how to get ID, CLASS and TAGS (full information with working code) /*This is the simple HTML and Javascript Code we will use */ <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <meta name="viewport" content="width=device-width, initial-scale=1.0">   <meta http-equiv="X-UA-Compatible" content="ie=edge">   <title>Test Page</title> </head> <body>     <div class="wrapper">         <div id="header">           <h1 class="header-tag" style="text-align:center; color:red;">THIS IS A SAMPLE SITE</h1>           <div id="main">             <ul>               <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis molestias enim adipisci nisi, aut official.HELLO</li>    ...