首页 > Windows开发 > 详细

JS篇 jQuery官方API使用笔记

时间:2015-01-06 17:20:26      阅读:238      评论:0      收藏:0      [点我收藏+]

  使用jQuery时,有些API容易混淆,通过API、源码记录心得如下:

 

1. $elem.attr() 、 $elem.prop()

  1) Attribute values are strings with the exception of a few attributes such as value and tabindex.

  Attribute值通常是string类型,除了一些其他的属性,如:value, tabindex.

  2) DOM Element Properties generally affect the dynamic state of a DOM element without changing the serialized HTML attribute. .prop() should be used when setting selectedIndex, tagName, nodeName, nodeType, ownerDocument, defaultChecked, or defaultSelected, checked, disabled, selected.

  DOM元素的property通常会改变节点的动态状态,如:checked, disabled, selected.

  总结:通常使用.attr(),如果是.prop()则针对上面的属性;

 

JS篇 jQuery官方API使用笔记

原文:http://www.cnblogs.com/diydyq/p/4206401.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!