document.getElementById (id): Returns the first record matching the id attribute.
document.getElementsByName (name): Returns all records matching the name attribute.
document.getElementsByTagName: Returns all records that match the tag name as an array.
document.getElementsByClassName (className): Returns all records that match the class attribute.
document.querySelector: selects the first record that matches the selector.
document.querySelectorAll (selector): Return all records matching the selector to the array.
document.getElementById (id). Returns the first record matching the id attribute.
document.getElementsByName (name). Returns all records matching the name attribute.
document.getElementsByTagName. Returns all records that match the tag name as an array.
document.getElementsByClassName (className). Returns all records that match the class attribute.
document.querySelector. selects the first record that matches the selector.
document.querySelectorAll (selector). Return all records matching the selector to the array.
document.getElementById
<p id="tex">Codeblog</p>
<script>
var obj = document.getElementById("tex");
document.write(obj)
</script>
document.getElementsByName
<p name="tex">Codeblog</p>
<script>
var obj = document.getElementByName("tex");
document.write(obj)
</script>
document.getElementsByTagName
<p>Codeblog</p>
<script>
var obj = document.getElementsByTagName("p");
document.write(obj)
</script>
document.getElementsByClassName
<p class="tex">Codeblog</p>
<script>
var obj = document.getElementsByTagName("tex");
document.write(obj)
</script>
document.querySelector
<p class="tex">Codeblog</p>
<script>
var obj = document.querySelector(".tex");
document.write(obj)
</script>
Leave a comment