div 标题上的 jQuery 1.6 prop()
可能的重复:
.prop() 与 .attr()
有什么区别
$('div').prop('title','whatever'); //set
$('div').prop('title'); //get
Doing和
$('div').attr('title','whatever'); //set
$('div').attr('title'); //get
prop() 对于 div 属性,
的行为似乎与 attr()
相同。我阅读了 1.6 文档,但我仍然有点困惑。
这不是完全重复 .prop() 与 .attr() 。这篇文章没有回答这个问题。请不要关闭它。
Possible Duplicates:
.prop() vs .attr()
What is the differnece between doing
$('div').prop('title','whatever'); //set
$('div').prop('title'); //get
and
$('div').attr('title','whatever'); //set
$('div').attr('title'); //get
prop()
seems to behave the same as attr()
in the case of div attribute. I read the 1.6 documentation for this but i'm still a little confused.
THIS IS NOT EXACT DUPLICATE OF .prop() vs .attr(). This post doesn't answer the question. Please do not close it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
prop
和attr
并不总是给出不同的结果。仅当属性和属性之间存在差异时,它们才会给出不同的结果。例如,使用
checked
属性/属性:这在
上都有很好的解释prop
与attr
。但是,对于
title
属性/属性来说,没有区别。它们都是字符串,设置其中一个会将另一个设置为该值。prop
andattr
do not always give different results. They only give different results when there is a difference between a property and an attribute.For instance, with the
checked
attribute/property:This is all well explained on
prop
vsattr
.However, with the
title
attribute/property, there is no difference. They are both strings, and setting one will set the other to that value.