in accessing an element with an id attribute you can use document.getElementById
HTML Code:
<p id="p1">Paragraph 1</p>
<p id="p2">Paragraph 2</p>
<p>Paragraph 3</p>
<script type="text/javascript">
var p2 = document.getElementById('p2'); // this will return the paragraph tag with the id of p2
</script> in accessing elements by their tag name you can use document.getElementsByTagName
HTML Code:
<p id="p1">Paragraph 1</p>
<p id="p2">Paragraph 2</p>
<p>Paragraph 3</p>
<script type="text/javascript">
var paragraphTags = document.getElementsByTagName('p'); // this will return an array of all the <p> elements
</script>
you can refer to this page for more information: https://developer.mozilla.org/en-US/...cument#Methods
please note that the link is for gecko based browsers which are also used in different browsers sometimes other browsers have their version of a function
Bookmarks