@@ -1592,6 +1592,19 @@ This article will show you how to use JavaScript to get value by class name. To
15921592```
15931593
15941594<h4 >Output:</h4 >
1595+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1596+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~ 23. ~~~~~~~~~~~~~~~~-->
1597+ <p align =" center " >
1598+ <a href=""
1599+ target="_ blank" rel="noopener noreferrer">
1600+ <img class="displayed"
1601+ src="./images/image023.gif?raw=true"
1602+ loading="lazy"
1603+ style="width:40%;"
1604+ title=""
1605+ alt="." />
1606+ </a >
1607+ </p >
15951608<!-- image023.gif -->
15961609
15971610<h4 >Example 2: In this example, we will get the second element by class name.</h4 >
@@ -1653,8 +1666,19 @@ This article will show you how to use JavaScript to get value by class name. To
16531666```
16541667
16551668<h4 >Output:</h4 >
1656-
1657-
1669+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1670+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~ 24. ~~~~~~~~~~~~~~~~-->
1671+ <p align =" center " >
1672+ <a href=""
1673+ target="_ blank" rel="noopener noreferrer">
1674+ <img class="displayed"
1675+ src="./images/image024.gif?raw=true"
1676+ loading="lazy"
1677+ style="width:40%;"
1678+ title=""
1679+ alt="." />
1680+ </a >
1681+ </p >
16581682<!-- image024.gif -->
16591683
16601684<h2 >How To Get Element By Class Name In JavaScript?</h2 >
@@ -1723,7 +1747,20 @@ In this approach we are using the document.getElementsByClassName() method. This
17231747```
17241748
17251749<h4 >Output:</h4 >
1726- <!-- image025 -->
1750+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1751+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~ 25. ~~~~~~~~~~~~~~~~-->
1752+ <p align =" center " >
1753+ <a href=""
1754+ target="_ blank" rel="noopener noreferrer">
1755+ <img class="displayed"
1756+ src="./images/image025.png?raw=true"
1757+ loading="lazy"
1758+ style="width:40%;"
1759+ title=""
1760+ alt="." />
1761+ </a >
1762+ </p >
1763+ <!-- image025.png -->
17271764
172817652 . Using document.querySelector()
17291766In this approach we are using the document.querySelector() method. This method returns the first element that matches the specified selector (class name). It is useful when you only need to select a single element by class name.
@@ -1769,6 +1806,19 @@ In this approach we are using the document.querySelector() method. This method r
17691806```
17701807
17711808<h4 >Output:</h4 >
1809+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1810+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~ 26. ~~~~~~~~~~~~~~~~-->
1811+ <p align =" center " >
1812+ <a href=""
1813+ target="_ blank" rel="noopener noreferrer">
1814+ <img class="displayed"
1815+ src="./images/image026.png?raw=true"
1816+ loading="lazy"
1817+ style="width:40%;"
1818+ title=""
1819+ alt="." />
1820+ </a >
1821+ </p >
17721822<!-- image026.png -->
17731823
17741824<h3 >3. Using document.querySelectorAll()</h3 >
@@ -1823,6 +1873,19 @@ In this approach we are using the document.querySelectorAll() method. This metho
18231873```
18241874
18251875<h4 >Output:</h4 >
1876+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
1877+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~ 27. ~~~~~~~~~~~~~~~~-->
1878+ <p align =" center " >
1879+ <a href=""
1880+ target="_ blank" rel="noopener noreferrer">
1881+ <img class="displayed"
1882+ src="./images/image027.png?raw=true"
1883+ loading="lazy"
1884+ style="width:40%;"
1885+ title=""
1886+ alt="." />
1887+ </a >
1888+ </p >
18261889<!-- image027.png -->
18271890
18281891
0 commit comments