This is not a duplicate question, I only need to decide whether to use / fast / correct to use attr or to use prop . The easiest and most reliable way is to check the list. "A list of element names where it is better to use prop(name) and / or a list of where it is better to use attr(name) ."
PS: I am using jQuery 1.9+, and suppose attr() not an obsolete method.
Example solutions (where LIST has the answer):
- is it better to get the ID value on
$(x).prop('id') or $(x).attr('id') ? - is it better to change the name with
$(x).prop('title','BLABLA') or with $(x).attr('title','BLABLA') ? - Is it possible to use
$(x).attr('selectedIndex') ? - Which properties have a risk with Cross Browser Context ?
- Is there any case (with Microsoft-IE p.ex.) where
$(x).attr('name') and $(x).prop('name') will return different things?
Perhaps a complete list is not needed, but only a list of things that may affect jQuery or its risk.
Edited after closing: click the REOPEN link below to accept this edited question text.
javascript jquery attr prop
Peter Krauss Feb 24 '13 at 22:13 2013-02-24 22:13
source share