Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...




What is difference between prop and attr?



​ What is difference between prop and attr?..

Answer / 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

More jQuery Interview Questions

Define the use of each function in jquery?

0 Answers  


Explain various methods to make ajax request in jquery? : jquery mobile

0 Answers  


How to load jQuery locally when CDN fails?

1 Answers  


Do we need to add the jquery file both at the master page and content page as well?

0 Answers  


What is the difference between jquery.size() and jquery.length?

1 Answers  


How do I check if an HTML element is empty using jQuery?

0 Answers  


With jquery which operating system is more compatible?

0 Answers  


what does $("div") will select? : jquery mobile

0 Answers  


How to use jquery library in our asp.net project?

0 Answers  


What are selectors in jquery? : jQuery Mobile

0 Answers  


What is the difference between text() and html() in jquery?

0 Answers  


Explain why there are two different version of jquery library? : jquery mobile

0 Answers  


Categories