HTML attributes and DOM properties are related but distinct concepts. Attributes are what you see in the HTML source; properties are the live JavaScript values that the browser derives from them and updates as the user interacts with the page. jQuery provides .attr() for attributes and .prop() for properties.
When to Use .attr()
Use .attr() when you need the original HTML attribute value — for example, the href as written in the source, the id, or a custom data-* attribute. It reflects the markup, not the current state.
When to Use .prop()
Use .prop() for boolean attributes such as checked, disabled, and selected, where you care about the current live state. .attr('checked') tells you whether the attribute was present at parse time; .prop('checked') tells you whether the checkbox is checked right now.
.attr('href')— original attribute string.prop('checked')— live boolean state.removeAttr('disabled')— remove an attribute entirely.data('key')— read adata-*attribute (with caching)
jQuery's .data() method reads data-* attributes on first access, then stores any subsequent writes in internal jQuery cache — it does not write back to the DOM attribute.