Thakzk
Thakzk
Example:
<a href="http://www.amazon.com">Shop</a>
Here:
Custom attributes (like data-*) are often used for storing extra information.
<div id="product" title="snacks">Cookies</div>
<script>
// Select the element by ID
var product = document.getElementById("product");
console.log(img.outerHTML);
// Output: <img id="profile" src="user.png" alt="User Profile Picture" width="100">
</script>
6. Final Notes
Using these methods with getElementById, you can dynamically interact with HTML
elements and their attributes to create engaging and functional web applications!