Element Attributes

Functions for getting and setting DOM attributes of elements.

Set, get, and remove properties of DOM elements

Get the value of an input field or the href of an anchor. Learn how to work with element properties.

jQuery: $.prop()

Adding, removing, and testing for classes

addClass, removeClass, hasClass - three important functions for working with DOM element classes.

jQuery: $.addClass, $.removeClass, $.hasClass, $.toggleClass

Setting, getting, and removing data attributes

Read, write, or remove data values of an element.

jQuery: $.data()

Getting, setting, and removing attributes

getAttribute, setAttribute, removeAttribute - modify attributes, such as id, alt, title and more.

jQuery: $.attr()