Get the value of the target attribute of an element: let text = If the given attribute does not exist, the value returned will either be null or "" (the JavaScript. W3Schools offers free online tutorials, references and exercises in all the major languages of the web. 1. How it works: First, select the link element with the id js using the querySelector () method. Youll get px from getComputedStyle, not relative units like em and rem. const val = document.querySelector('input')value; console.log(val); } The inputs value will be printed to the console when the getVal () function is invoked. - entityType: select box get get selected value jquery. Get the value of the class attribute of an element: let text = element.getAttribute("class"); Try it Yourself . Specifies the attribute to get the attribute value from In this article, we will learn about the HTML DOM getAttribute() method, along with understanding their implementation through the example.. HTML DOM getAttribute() method is used to get the value of the attribute of the element. In JavaScript, The document.getElementsByTagName () method can be used to get the value of the id attribute of a link or anchor tag. Syntax. The property can also be assigned a value, so we can set the value of the data-fruit attribute by writing: plant.dataset.fruit = 10 jQuery. A contact lookup field is of type EntityReference. jQuery lets us get a value of an attribute that starts with data-with various ways. Example