The attr() method sets or returns attributes and values of the selected elements. When this method is used to return the attribute value, it returns the value of theof the first matched element. When this method is used to set attribute values, it sets one or more attribute/value pairs for the set of matched elements.

$(selector).attr(attribute);           //it will return the value of an attribute.

$(selector).attr(attribute,value);     //it will set the value of an attribute.

$(selector).attr({attribute:value, attribute:value,...})      //for set multiple attribute.

More on jQuery

Leave a Reply

Your email address will not be published. Required fields are marked *

Explore More

How to Center a Popup Window on Screen

JavaScript window.open() method is used to open a popup window. This popup window will be placed in the center of the screen. This example creates the pop-up window without placing it into

How to hide URL in the popup window opened using window.open

If you are using below code to open a popup window in your web page, then address must be appearing in you pop up window and f you want to

window.showModalDialog is deprecated in Edge and Chrome

If you have a website being compatible with Edge/Chrome and in past it was only compatible with IE 11 and if you are using window.showModalDailog in your JavaScript code, then