zoukankan      html  css  js  c++  java
  • 有关innerHTML的知识

    object.innerHTML: object所包含的元素的HTML,不包含object
    object.outerHTML: object及它所包含元素的HTML,包含object

    <a href="#" onclick="alert(this.innerHTML)">this is innerHTML</a><br>
    <a href="#" onclick="alert(this.outerHTML)">this is outerHTML</a><br>

    来个应用的
    <a href="#" onclick="this.innerHTML='<p onclick=alert(this.outerHTML)>this is outerHTML</p>' ">this is innerHTML</a>
    上面都是采用的this本身,下面采用id对应object
    <button onclick=alert(obj1.innerHTML)>obj1.innerHTML</button>

    <button onclick=alert(obj2.outerHTML)>obj2.outerHTML</button>

    <div id=obj1><font color=blue>cnbruce</font></div>

    <div id=obj2><font color=red>cnrose</font></div>

    innerText

    <SELECT NAME="cn_who">
    <option value="male">cnbruce</option>
    <option value="female">cnrose</option>
    </SELECT>

    <INPUT TYPE="button" VALUE="The Node" onClick="alert(cn_who.children[0].nodeName)">
    <INPUT TYPE="button" VALUE="The Name" onClick="alert(cn_who.children[0].innerText)">
    <INPUT TYPE="button" VALUE="The Sex" onClick="alert(cn_who.children[0].value)">
    <INPUT TYPE="button" VALUE="The Node" onClick="alert(cn_who.children[1].nodeName)">
    <INPUT TYPE="button" VALUE="The Name" onClick="alert(cn_who.children[1].innerText)">
    <INPUT TYPE="button" VALUE="The Sex" onClick="alert(cn_who.children[1].value)">

    insertAdjacentText
     
    <a href="#" onclick="this.insertAdjacentText('afterEnd',' cnbruce ')">insertAdjacentText</a>

    申明

    非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!

    博文欢迎转载,但请给出原文连接。

  • 相关阅读:
    spring-data-elasticsearch (elasticsearch 6.7.0) @Document 和 @Field 注解详解
    干货链接(大神)
    Excel word PDF导入导出 Easy POI
    helm 源大集合
    K8s学习干货
    K8S
    阳明大神---容器时代
    K8s高可用集群部署
    最小 docker_lpnm系统
    python 协程和异步编程全解
  • 原文地址:https://www.cnblogs.com/Athrun/p/1200603.html
Copyright © 2011-2022 走看看