<Js>事件

来源:互联网 发布:百度seo教程 编辑:程序博客网 时间:2024/06/05 03:51

基本的点击:

<p onclick="this.innerHTML='变化了'">点击</p>

function事件:

<h1 onclick="changetxt(this)">这是</h1><script>    function changetxt(wen){        wen.innerHTML = "什么?";          }</script>

点击事件:

<input type="button" value="请点击"    onclick="fun()"/><script>    function fun(){    document.getElementById("but").innerHTML=Date();        }//或document.getElementById("but").onclick=function(){fun()};    </script>

cookies:

<body onload/onunload="fun()"><script>    function fuN(){            if(navigator.cookieEnabled==true){ alert("启用了cookie");}else{    alert("没有启用");   }}</script></body>

自动变大写:

输入英文:<input type="text" id="eng" onchange = "My()"><script>    function My(){    var x =document.getElementById("eng");    x.value = x.value.toUpperCase();    }</script>

移动和离开:

<div onmouseover = "A(this)" id="sd" onmouseout = "B(this)">上面!!!!</div><script>    function A(){    //obj.innerHTML = "over";    document.getElementById("sd").innerHTML="over";    }    function B(){    //obj.innerHTML = "out";    document.getElementById("sd").innerHTML="out";    }</script>

点击改变:

<span onmousedown = "C(this)" id="sdd" onmouseup = "D(this)">..</span><script>function C(){var gur =document.getElementById("sdd");gur.innerHTML="另一个C";document.getElementById("sdd").style.color="red";}function D(){                    document.getElementById("sdd").innerHTML="out";        document.getElementById("sdd").style.background="yellow";        }    </script>
0 0
原创粉丝点击