<!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>