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?

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


Please Help Members By Posting Answers For Below Questions

How to write cookies in jquery?

4005


Why are not some scripts and styles loading? : jquery mobile

769


How can related code be encapsulated?

833


What is queue() in jquery? Use of queue() in jquery?

774


What are features of jquery or what can be done using jquery?

787


What are some of the ways to provide effects? : jQuery Mobile

763


List the advantage of using minimized version of jquery?

728


Difference between prop() and attr()? : jQuery Mobile

795


How can we apply css in even childs of parent node using jquery library?

857


What is the use of param() method?

890


Define jquery filter?

820


What programming language does jquery use?

789


Define jquery $.ajax() method?

836


Tell me does jquery 2.0 supports ie? : jquery mobile

733


What are the methods used to provide effects in jquery?

734