Answer Posted / chaitanya
attr(): Get the value of an attribute for the first element in the set of matched elements. Whereas,.prop(): (Introduced in jQuery 1.6) Get the value of a property for the first element in the set of matched elements.
Attributes carry additional information about an HTML element and come in name="value" pairs. Where Property is a representation of an attribute in the HTML DOM tree. once the browser parse your HTML code ,corresponding DOM node will be created which is an object thus having properties.
attr() gives you the value of element as it was defines in the html on page load. It is always recommended to use prop() to get values of elements which is modified via javascript/jquery , as it gives you the original value of an element's current state. Find out more here.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain the basic need to start with jquery? : jquery mobile
What are your tools of choice to get the jquery job done?
Please tell us that is jquery knockkout intended to compete with jquery or prototype or work with it?
What is the name of jquery method used for an asynchronous http request?
What is jQuery CDN?
Explain why there are two different version of jquery library? : jquery mobile
Tell me can we have multiple document.ready() function on the same page? : jquery mobile
Explain the each() function?
What is the method used to define the specific character in place of $ sign?
How can we apply css in last child of parent using jquery library?
How we can remove an attribute of an html tag in jquery?
How to validate email using jquery?
Will Events Are Also Copied On Clone In Jquery?
Define "beforesend(xhr)" paremeter of jquery ajax method?
How do you disable or enable a form element?