最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

javascript簡(jiǎn)單事件處理和with用法介紹

 更新時(shí)間:2013年09月16日 10:10:12   作者:  
本文為大家介紹下javascript事件處理及with用法,主要是鼠標(biāo)點(diǎn)擊與移動(dòng),感興趣的朋友可以參考下
這一期介紹一些簡(jiǎn)單的事件處理:
1.鼠標(biāo)點(diǎn)擊
復(fù)制代碼 代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">

<script type="text/javascript">
function click1(obj)
{
alert(obj.innerHTML);
}
</script>
</head>

<body>
<div onclick="click1(this)" style="cursor:pointer">點(diǎn)擊我吧</div>
</body>
</html>

this即div的上下文,點(diǎn)擊后會(huì)彈出<div>之間的內(nèi)容。
2.鼠標(biāo)移動(dòng)
復(fù)制代碼 代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">

<script type="text/javascript">
function mouse1(obj)
{
obj.style.color = "#f00";
obj.style.fontSize = "18px"
}
function mouse2(obj)
{
obj.style.color = "#000";
obj.style.fontSize = "16px"
}
</script>
</head>

<body>
<div onmouseover="mouse1(this)" onmouseout="mouse2(this)">移動(dòng)到這兒</div>
</body>
</html>

onmouseover鼠標(biāo)放到那兒時(shí),會(huì)把字體變大,字體成為紅色,離開(kāi)時(shí)字體和顏色恢復(fù)。
3.with用法
復(fù)制代碼 代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">

<script type="text/javascript">
with(document)
{
write("niujiabin"+"<br/>");
write("maybe"+"<br/>");
write("gossip"+"<br/>");
}
</script>
</head>
<body>
</body>
</html>

效果與如下相同
復(fù)制代碼 代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">

<script type="text/javascript">
document.write("niujiabin"+"<br/>");
document.write("maybe"+"<br/>");
document.write("gossip"+"<br/>");
</script>
</head>
<body>
</body>
</html>

相關(guān)文章

最新評(píng)論

吴旗县| 奈曼旗| 大兴区| 米泉市| 白山市| 锡林浩特市| 麻阳| 吉安县| 报价| 上蔡县| 通河县| 洛宁县| 咸宁市| 道孚县| 雅江县| 武功县| 武山县| 灵石县| 定襄县| 固阳县| 桦甸市| 新昌县| 克山县| 新津县| 白水县| 清丰县| 江源县| 谷城县| 扬州市| 红桥区| 石渠县| 乌鲁木齐县| 汝州市| 遵义市| 平利县| 崇仁县| 和硕县| 云梦县| 洪湖市| 潞城市| 永顺县|