html5 自定义标签取值

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
<script>
window.onload=function(){
/*    var oDiv=document.getElementById('div1');
    alert(oDiv.dataset.yaoyuan);*/

    var oDiv=document.getElementById('div2');
    alert(oDiv.dataset.yaoyuanTop);
}
</script>
</head>
<body>
    <div id="div1" data-yaoyuan="遥远">div</div>
    <div id="div2" data-yaoyuan-top="遥远2">div2</div>
</body>
</html>

 

posted @ 2017-01-02 17:51  distant-遥远  阅读(1056)  评论(1编辑  收藏  举报