What is the difference between .attr() and .prop() methods in jQuery?
Description : The .attr() method sets or retrieves attribute values, while .prop() deals with properties of DOM elements.
Answer :
In jQuery,`.attr()` and `.prop()` are used to access and manipulate different aspects ofDOM elements.`.attr()` is used to get or set attributes like `href`,`id`, and `src`as defined inHTML. For example,`$('a').attr('href', 'https://example.com')` sets the `href` attribute. Conversely,`.prop()` is used to work with properties such as`checked`,`disabled`, or `selected`, which reflect the current state of the element. For example,`$('input').prop('checked', true)` sets a checkbox to be checked.`.prop()` is generally used for properties that change dynamically,while`.attr()` is more suited forstatic attributes.