写出3个使用this的典型应用
1、在html元素事件属性中使用,如:
<input type=”button” οnclick=”put(this);” value=”点击一下”/>
2、构造函数
function click(name, color) {
this.name = name;
this.color = color;
}
3、input点击,获取值
<input type="button" id="put" value="点击一下" />
<script type="text/javascript">
var btn = document.getElementById("put");
btn.onclick = function() {
alert(this.value); //此处的this是按钮元素
}
</script>
来源:CSDN
作者:&星期八&
链接:https://blog.csdn.net/qq_38881495/article/details/98957896