• 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);
    
  • 相关阅读:
    codeforces
    hdu
    hdu
    poj 2823
    hdu
    hdu
    hdu
    微信公众号 SDK
    PHP 正则表达式
    注册和登录时的验证码
  • 原文地址:https://www.cnblogs.com/wddx/p/5153496.html
Copyright © 2020-2023  润新知