3个使用this的案例

1、<input type="button" onclick="showInfo(this)" value="点击">

2、 function people(name,age) {
        this.name=name;
        this.age=age;
    }

3、<input type="button"  id="box" value="点击">

     <script type="text/javascript">
       var box1=document.getElementById("box")

       box1.onclick=function(){

        alert(this.value);    //按钮元素
    }

猜你喜欢

转载自blog.csdn.net/qq_42540989/article/details/85000168