jQuery attr vs. prop, there are a list of props?
This is not a duplicate question, I need only to decide if the better/fast/correct is to use attr
or to use prop
. The simplest and reliable way is checking into a list. A "list of element-name where the better is use prop(name)
and/or a list where the better is use attr(name)
".
PS: I am using jQuery 1.9+, and suppose that attr()
is not a deprecated method.
Example of decisions (where the LIST have the answer):
$(x).prop('id')
or by $(x).attr('id')
? $(x).prop('title','BLABLA')
or with $(x).attr('title','BLABLA')
? $(x).attr('selectedIndex')
? $(x).attr('name')
and $(x).prop('name')
will return different things? Perhaps a full list is not necessary, only a list of things that make some difference or risk for jQuery.
Edited after close: please click in the REOPEN link below to accept this edited question text.
它们从浏览器到浏览器有所不同,但这里是IE列表... http://msdn.microsoft.com/en-us/library/ie/hh773183(v = vs.85).aspx
看看https://developer.mozilla.org/en-US/docs/DOM/element#Properties,并考虑许多属性仅适用于特殊类型的元素。
链接地址: http://www.djcxy.com/p/4736.html