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

Explore More

Open a Fixed-Size Popup Without Minimize/Maximize Effects

Disabling the minimize and maximize buttons of a popup window is not directly supported in modern browsers, including Microsoft Edge, due to security and user-experience considerations. The window.open() function provides

How to remove JavaScript Objects from memory

To remove unused objects and improve memory management in JavaScript, you generally rely on the JavaScript engine’s garbage collection mechanism. However, you can aid this process by explicitly removing references

addchild and removeChild DOM methods for Edge and Chrome

Below we are creating a JavaScript utility that fully supports the functionality of the DOM (like appendChild, removeChild, etc.) in Microsoft Edge and other modern browsers involves wrapping standard DOM