|
|
@@ -0,0 +1,22 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div id="box" data-aa="你好" data-aa-bb="ab"></div>
|
|
|
+ <script>
|
|
|
+ const box1 = document.getElementById("box");
|
|
|
+ box1.setAttribute('address','哈尔滨');
|
|
|
+ console.log(box.getAttribute("address"));
|
|
|
+ box1.dataset.bb = 'hi';
|
|
|
+ console.log(box1.dataset.aa);
|
|
|
+ console.log(box1.dataset.bb);
|
|
|
+ console.log(box1.dataset.aaBb);
|
|
|
+ box1.cc = '12';
|
|
|
+ console.log(box1.cc);
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|