设置函数触发间隔时间:
setTimeout("_name", 1000);
鼠标放在元素上触发事件:
<a href="" style="font-size:20px;color:cadetblue;text-align:start;width:100%" onmouseover="mOver(this)" onmouseout="mOut(this)">返回首页</a>
<a href="" style="font-size:20px;color:cadetblue" onmouseover="mOver(this)" onmouseout="mOut(this) " id="change">点击刷新</a>
JS:
<script>
function mOver(x) { x.style.fontSize = "25px";}
function mOut(x) { x.style.fontSize = "20px"; }
</script>
加载页面提示:
<body onload="tishi(); tishi1()">
JS:
function tishi() { alert('欢迎进入!'); }
function tishi1() { alert('欢迎进入1!'); }
点击替换文本:
<div style="width:100%;height:50px;">
<h1 onclick="ccc(this)">dianwo</h1>
</div>
JS:
function ccc(x) { x.innerHTML = '111';}
点击按钮显示日期:
<div>
<button onclick="displayData()" >点击</button>
<p id="demo"></p>
</div>
JS:
function displayData() {document.getElementById('demo').innerHTML = Date();}
文本框小写转大写,改变背景颜色:
<div style="width:100%;height:80px;">
<p>大写转小写</p>
输入你的名字:<input type="text" id="fname" onchange="myFunction()" onfocus="focuss(this)">
</div>
JS:
function myFunction() {var x = document.getElementById('fname');x.value = x.value.toUpperCase();}
function focuss(x) { x.style.background = "yellow"; }
鼠标点击事件:
<div onmousedown="mDown(this)" onmouseup="mUp(this)" style="background-color:burlywood;width:100px;height:50px;padding:40px">点击</div>
JS:
function mDown(x) { x.style.backgroundColor = "blue"; x.innerHTML = '变变变'; }
function mUp(x) { x.style.backgroundColor = "green"; x.innerHTML = '结束'; }