标签:
取得元素
dataset属性
DOMStringMap Object
<!doctype html> <html> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> </head> <body> <div id="a" data-title="asd">asd</div> </body> <script> var a=document.getElementById("a"); console.log(a.dataset.title); a.dataset.title="qqq"; console.log(a.dataset.title); delete a.dataset.title; a.dataset.camelName="qqq"; console.log(a.dataset) </script> </html>
包含驼峰变量转换(类似angularjs中的derective名称转换)
标签:
原文地址:http://www.cnblogs.com/carlyin/p/5872484.html