js-可以使用id直接操作DOM

//一般不建议使用,可以在console调试时使用
<input type="button" id="btn" value="anniu">
<script>
    btn.onclick=function(){
        console.log('hello');   //结果弹出 --hello
    }
    location.onclick=function(){
        console.log('location');  //无任何输出--因为window自带locaiton属性,此时window的location属性,覆盖了id为location的标签
    }
</script>
原文地址:https://www.cnblogs.com/sakura-sakura/p/6856839.html