zoukankan      html  css  js  c++  java
  • html节点属性操作

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
      <meta name="author" content="" />
      <style type="text/css"></style>
      <script type="text/javascript">
      //当网页加载完成调用js程序
     //匿名函数:就是没有名字的函数,不能单独定义,也不能单独调用
     //匿名函数只能作为数据传给其他变量
    
      window.onload=function(){
            //查找img节点
            var imgObj=document.body.firstChild;
            //添加src属性
            imgObjAttribute("src","images/01.jpg");
            //添加width属性
            imgObj.setAttribute("width","500");
            //添加border属性
            imgObj.setAttribute("border",2);
            //添加onclick属性
            imgObj.setAttribute("onclick","removeImg(this)");
      }
        //删除src属性
      function removeImg(imgObj){
          imgObj.removeAttribute("src");
      }
    
    
      /*匿名函数调用和作为数据
    //给变量赋不同的值,则变量就是不同类型
    //给变量赋一个函数,则变量就是函数型
      var a="abc";
      var a=[10];
      var a= function(){
            alert("ok");
      }
      //调用方法:
      a();  
      */
      </script>
     </head>
     <body>    
            <body><img onclick="removeImg(this)" /></body>
     </body>
    </html>
  • 相关阅读:
    公平锁和非公平锁
    读写锁StampedLock的思想
    线程工作窃取算法
    关于SQL注入的问题以及解决方法
    简单工厂模式、工厂模式和抽象工厂模式
    RestFul的无状态规则详解
    Identity Server 4 中文文档(v1.0.0) 目录
    第3章 支持和规范
    第2章 术语
    第1章 背景
  • 原文地址:https://www.cnblogs.com/yangzailu/p/6089669.html
Copyright © 2011-2022 走看看