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
What is difference between sorting string array and sorting numerical array in jquery?
Which command will give a version of jQuery?
Define data paremeter of jquery ajax method?
What were the biggest challenges of getting the 1.7 release out there?
Define slidetoggle() effect?
How to resolve conflicts with other libraries?
What are the advantages of jQuery?
How to disable cut,copy and paste in TextBox using jQuery?
Tell me is jquery a library for client scripting or server scripting? : jquery mobile
What is jQuery code to select all links in first paragraph?
Why we need jquery?
Explain the basic need to start with jquery? : jquery mobile
Tell me does jquery 2.0 supports ie? : jquery mobile
Explain .live()? : jquery mobile
Is jquery a library for client scripting or server scripting? : jquery mobile