zoukankan      html  css  js  c++  java
  • javascript

    1、改变HTML输出流

      document.write(Date());

    2、改变HTML内容

      document.getElementById("p1").innerHTML="New text!";

    3、改变HTML属性

      document.getElementById("image").src="/E:/技术学习/前端/i/shanghai_lupu_bridge.jpg";

    4、改变HTML样式

      document.getElementById("p2").style.color="blue";

    5、HTML事件属性

    <button onclick="displayDate()">点击这里</button>
    <script>
    	function displayDate()
    	{
    		document.getElementById("de").innerHTML=Date();
    	}
    </script>
    <p id="de"></p>
    

     6、鼠标事件

    <div onmousedown="mDown(this)" onmouseup="mUp(this)" style="background-color:green; 120px;height:20px; padding:40px; color:#ffffff;">把鼠标移到上面</div>
    <script>
    	function mDown(obj)
    	{
    		obj.innerHTML="谢谢";
    		obj.style.backgroundColor="#1ec5e5";
    	}
    	function mUp(obj)
    	{
    		obj.innerHTML="把鼠标移到上面";
    		obj.style.backgroundColor="green";
    	}
    </script>
    

     7、创建新节点

    var para=document.createElement("p");
    var node=document.createTextNode("这是新段落");
    para.appendChild(node);
    var element=document.getElementById("div1");
    element.appendChild(para);
    

     8、删除新节点

    var child=document.getElementById("p1");
    child.parentNode.removeChild(child);
    
  • 相关阅读:
    [bzoj2038] [2009国家集训队]小Z的袜子
    浅谈莫队
    [bzoj2754] [SCOI2012]喵星球上的点名
    [bzoj3676] [APIO2014]回文串
    [bzoj5472] 数列
    [bzoj5457] 城市
    [bzoj1023] [SHOI2008]cactus仙人掌图
    [bzoj2125] 最短路
    [bzoj5473] 仙人掌
    读《深入理解Elasticsearch》点滴-查询评分
  • 原文地址:https://www.cnblogs.com/wddx/p/5153496.html
Copyright © 2011-2022 走看看