繁体   English   中英

jQuery .data可以使用破折号访问驼峰式案例密钥

[英]jQuery .data can access camel case key using dash

任何人都可以解释为什么这样做: $('#someId').data('typeId', 2); $('#someId').data('type-id'); // will return 2 $('#someId').data('typeId', 2); $('#someId').data('type-id'); // will return 2

这也是小提琴: http : //jsfiddle.net/L6nLpgdb/

谢谢 !

检查此链接

The custom data attributes is transformed to a key for the DOMStringMap entry with the following rules:

    any dash (U+002D) is removed;
    any letter following a dash (U+002D), before its removal, is set in its uppercase counterpart.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM