操作方法
新建文件书写样式
引用样式
js获取div
弹出this
弹出this中的内容
定义函数弹出this
附上代码,总结this调用的是就近元素的上一级 <style> #box{width:300px; height:300px; background:red;} </style> <body> <div id="box">hello word</div> <script> var box = document.getElementById("box"); box.onclick = function(){ //alert(this.innerHTML); } dem(); function dem(){ alert(this.innerHTML); } </script>