zoukankan      html  css  js  c++  java
  • js---04 属性 this

        var oUl = document.getElementsByTagName('ul')[0];
        var aLi = oUl.getElementsByTagName('li');
        
        window.onload = function (){
            // document.title = 123;
            // document.body.innerHTML = 'abc';
            var aBtn = document.getElementsByTagName('input');    
            // alert(aBtn.length);
            document.body.innerHTML = '<input type="button" value="按钮" /><input type="button" value="按钮" /><input type="button" value="按钮" />';
            // alert(aBtn.length);
            aBtn[0].onclick = function (){ alert(1); };
            aBtn[1].onclick = function (){ alert(1); };
            aBtn[2].onclick = function (){ alert(1); };
            // 重复执行某些代码
            // 每次执行的时候,有个数字在变化
        }
        
        aLi[j].style.border = '1px solid red';
        oDiv.style.cssText = ' 200px; height:200px; ';
        alert(this);            window
    
        
    fn1(this);
    function fn1(obj){
        obj => window
    }
    oDiv.onclick = function (){
        fn2(this);
    };
    function fn2(obj){  obj => oDiv }
  • 相关阅读:
    显而易见的python
    GitHub 使用教程图文详解
    linux下搭建hexo环境
    linux 删除软链接
    Django2.1入门教程
    windows下安装PyQt4
    python3 Flask安装
    学习之源
    白话C++系列教程
    面试笔试试题精选
  • 原文地址:https://www.cnblogs.com/yaowen/p/6828747.html
Copyright © 2011-2022 走看看