How to call functions after previous function is completed in jQuery ? This method is used to add a specified attribute to an element, giving the attribute a certain value. The document contains a input element that has the id attribute with the value the my_id. The syntax is simple. If you need to change or assign a value to the onclick attribute of a DOM element, you have two options; you can use either plain Javascript or the popular jQuery library. getAttribute( ) returns the value of a named attribute of an element. If you'd like to modify an attribute of an Element on the fly, you can do so within your Javascript code using the Element.setAttribute method. How to detect when user scrolls to the bottom of a div ? The issue is I cannot get the multiple attribute to be set in the element. Any attribute on any element whose attribute name starts with data- is a data attribute. The value property sets or returns the value of the value attribute of a text field. Otherwise a blank value may be mistaken for its value. The getAttributeNames method returns an array of all attribute names (values are not returned). It is necessary to set the nodetext to add the this value attribute to the param element. To set a value of an attribute on an element, you use the setAttribute() method: The numbers in the table specify the first browser version that fully supports the method. The name of the attribute you want to add, Required. How to Dynamically Add/Remove Table Rows using jQuery ? Convenience: It can be called directly on a jQuery object and chained to other jQuery methods. Data Structures and Algorithms – Self Paced Course, Ad-Free Experience – GeeksforGeeks Premium, We use cookies to ensure you have the best browsing experience on our website. If so, change the value of the target attribute to "_self": HTML DOM Reference: getAttribute() Method, HTML DOM Reference: hasAttribute() Method, HTML DOM Reference: removeAttribute() Method. Add the class attribute with the value of "democlass" to a