jQuery(clipPathN).attr({
'data-boxwidth' : boxW,
'data-boxheight': boxH,
'data-shapid' : 'shapId' + clss,
'data-shaperatiochk': jQuery('#shapeRatioChk').prop('checked')
});
jQuery(clipPathN).data({
'boxwidth' : boxW,
'boxheight': boxH,
'shapid' : 'shapId' + clss,
'shaperatiochk': jQuery('#shapeRatioChk').prop('checked')
});
jQuery 同时出现 atrr() 和 data() 是为了兼容性问题吗?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
斯洛文尼亚旅游 2016-08-16 04:02关注attr是设置dom对象的属性(attribute),就是
<div id="xx" aa="自定义aa属性"里面的aa,id属性,值只能为字符串
data是在dom对象上缓存数据,可以为对象之类的数据
http://www.w3school.com.cn/jquery/data_jquery_data.asp
prop方法是设置dom对象的property,注意和attr的区分
jquery attr prop 区别解决 无用评论 打赏 举报