当前触发事件的两种方式(onclick) 和 ('id') 获取

1. 

  <input type='text' onclick = 'Clickon(this)'>

<script>

     function Clickon(num){

            num.style.backgroud = 'red'

}

</script>

2.  <input type='text' id='i1'>

<script>

    var tag = document.getElementById('i1')

    tag.onclick = function(){

    tag.style.background = 'red'

}

</script>

猜你喜欢

转载自www.cnblogs.com/my-love-is-python/p/9296729.html