.prop()与.data() [英] .prop() versus .data()

查看:80
本文介绍了.prop()与.data()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着 jQuery v1.6 的新版本的发布以及 .prop()方法。

With the new release of jQuery v1.6 and the addition of the .prop() method.

使用 .prop()是否存在内在差异超过 .data()

我在文档中看到,在IE9之前的IE版本中,不删除属性会导致内存泄漏。但使用新的 prop()方法是否存在任何其他性能问题或其他问题?

I see in the documentation that not removing a property can result in memory leaks in versions of IE prior to IE9. But are there any other performance issues or other issues with using the new prop() method?

来自的语法site:

var $para = $("p");    
$para.prop("luggageCode", 1234);

以下内容:

var $para = $("p");
$para.data("luggageCode", 1234);


推荐答案

我认为prop用于设置有效的HTML文档属性而不是任意数据。我建议你继续使用rowsCode类型信息的数据。

I believe prop is intended for setting valid HTML document properties, rather than arbitrary data. I'd suggest you continue to use data for luggageCode type info.

这篇关于.prop()与.data()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆