<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Element Access Methods Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/element-access-methods/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/element-access-methods/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Wed, 13 Apr 2022 16:30:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>How to Access an Element in HTML DOM using JavaScript?</title>
		<link>https://www.scmgalaxy.com/tutorials/how-to-access-an-element-in-html-dom-using-javascript/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-to-access-an-element-in-html-dom-using-javascript/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Fri, 06 Aug 2021 12:24:59 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Element Access Methods]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Node]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=7489</guid>

					<description><![CDATA[<p>Element Access Methods Method Description document.getElementById(“ID”) Get the element with the specified ID document.getElementsByTagName(“Tag_Name&#8221;); Get all the specified element by [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-access-an-element-in-html-dom-using-javascript/">How to Access an Element in HTML DOM using JavaScript?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading"><strong>Element Access Methods</strong></h2>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Method</strong></td><td><strong>Description</strong></td></tr><tr><td>document.getElementById(“ID”)</td><td>Get the element with the specified ID</td></tr><tr><td>document.getElementsByTagName(“Tag_Name&#8221;);</td><td>Get all the specified element by the Tag Name</td></tr><tr><td>document.getElementsByClassName(“Class_Name&#8221;);</td><td>Get all the specified element by the Class Name</td></tr><tr><td>document.querySelector(“CSS_Selector&#8221;);</td><td>It returns the first match of the passed selector string</td></tr><tr><td>document.querySelectorAll(&#8220;CSS_Selector&#8221;);</td><td>It returns a node list of DOM elements that match the query</td></tr></tbody></table></figure>



<h2 class="wp-block-heading">getElementById(“ID_Name”)</h2>



<p class="wp-block-paragraph">The method get<strong>E</strong>lement<strong>B</strong>y<strong>I</strong>d(“ID_Name”) returns an Element object representing the element whose id property matches the specified string. Since element IDs are required to be unique if specified, they&#8217;re a useful way to get access to a specific element quickly.</p>



<script src="https://gist.github.com/vijaypk376/6ddcfb35441e7833bc9eab2905a0f20c.js"></script>



<h2 class="wp-block-heading">getElementsByTagName(“Tag_Name”)</h2>



<p class="wp-block-paragraph">The method get<strong>E</strong>lements<strong>B</strong>y<strong>T</strong>ag<strong>N</strong>ame(“Tag_Name”) returns a live node list meaning that it updates itself with the DOM tree automatically, so modification of the DOM tree will be reflected in the returned collection. The returned Node List or Collection of Nodes can be accessed by index numbers starting with index 0.</p>



<ul class="wp-block-list"><li>This method accepts a string indicating the type of elements that be retrieved, a special value “ * ” returns all elements in the documents.</li><li>You can use the length property of the NodeList object to determine the number of elements with the specified tag name, then you can loop through all elements and extract the info you want.</li></ul>



<h2 class="wp-block-heading">getElementsByTagName(“Tag_Name”)</h2>



<script src="https://gist.github.com/vijaypk376/c4ec9fdfd468eda0c547fd9a74fb7aa4.js"></script>



<h2 class="wp-block-heading">getElementsByTagName(“Tag_Name”)</h2>



<h3 class="wp-block-heading"><strong>More specific</strong></h3>



<script src="https://gist.github.com/vijaypk376/beb049b4674e759296a1962317363db1.js"></script>



<h2 class="wp-block-heading">getElementsByTagName(“Tag_Name”)</h2>



<ul class="wp-block-list"><li><strong>Length Property</strong></li></ul>



<script src="https://gist.github.com/vijaypk376/3e235b9c309b2478a78618493f8ca8f9.js"></script>



<ul class="wp-block-list"><li><strong>Loop</strong></li></ul>



<script src="https://gist.github.com/vijaypk376/cd7e6ac24025066061affc0d6f8954f2.js"></script>



<h2 class="wp-block-heading">getElementsByClassName(“Class_Name”)</h2>



<p class="wp-block-paragraph">The Method getElementsByClassName() returns a live node list meaning that it updates itself with the DOM tree automatically, so modification of the DOM tree will be reflected in the returned collection. The returned Node List or Collection of Nodes can be accessed by index numbers starting with index 0.</p>



<p class="wp-block-paragraph">•This method accepts string indicating the class name of elements that be retrieved •</p>



<p class="wp-block-paragraph">We can also pass multiple class name. For matching, all the class names should match. •You can use the length property of the NodeList object to determine the number of elements with the specified class name, then you can loop through all elements and extract the info you want.</p>



<ul class="wp-block-list"><li>This method accepts string indicating the class name of elements that be retrieved</li><li>We can also pass multiple class name. For matching, all the class name should match.</li><li>You can use the length property of the NodeList object to determine the number of elements with the specified class name, then you can loop through all elements and extract the info you want.</li></ul>



<h2 class="wp-block-heading">getElementsByClassName(“Class_Name”)</h2>



<script src="https://gist.github.com/vijaypk376/fb2f06c98a6b2dc004f159ba5b0ccd25.js"></script>



<h2 class="wp-block-heading">getElementsByClassName(“Class_Name”)</h2>



<h3 class="wp-block-heading"><strong>More specific</strong></h3>



<script src="https://gist.github.com/vijaypk376/9014d51e812d909c9fd5fe8746735365.js"></script>



<h2 class="wp-block-heading">getElementsByClassName(“Class_Name”)</h2>



<ul class="wp-block-list"><li><strong>Length Property</strong></li></ul>



<script src="https://gist.github.com/vijaypk376/efc998b6f18351389c90af5f074475aa.js"></script>



<ul class="wp-block-list"><li><strong>Loop</strong></li></ul>



<script src="https://gist.github.com/vijaypk376/617c5755e99b6cf7272ee4cd5a79b905.js"></script>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-access-an-element-in-html-dom-using-javascript/">How to Access an Element in HTML DOM using JavaScript?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-to-access-an-element-in-html-dom-using-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
