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

javascript簡單事件處理和with用法介紹

 更新時(shí)間:2013年09月16日 10:10:12   作者:  
本文為大家介紹下javascript事件處理及with用法,主要是鼠標(biāo)點(diǎn)擊與移動(dòng),感興趣的朋友可以參考下
這一期介紹一些簡單的事件處理:
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ì)把字體變大,字體成為紅色,離開時(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)論

双鸭山市| 微博| 黄山市| 东丰县| 册亨县| 鄂温| 深水埗区| 万全县| 瓦房店市| 专栏| 灵武市| 连山| 波密县| 广安市| 五莲县| 东乌珠穆沁旗| 海口市| 泗洪县| 苏尼特左旗| 郓城县| 龙游县| 卓尼县| 普宁市| 木兰县| 玉林市| 平定县| 廉江市| 南汇区| 玉树县| 张家口市| 玉林市| 吉木萨尔县| 故城县| 张家港市| 开平市| 锦屏县| 曲麻莱县| 扎鲁特旗| 呼图壁县| 临猗县| 乌拉特中旗|