您的位置:首页 > Web前端 > JavaScript

js通过获取id和name改变图片

2012-07-31 11:29 609 查看




<html>
<head>
<script type="text/javascript">
<!--
function one(){
document.getElementById('ok').style.background='url(http://d.lanrentuku.com/down/png/1205/angrybirds.jpg)';
}
function two(){
document.getElementById('ok').style.background='url(http://d.lanrentuku.com/down/png/1110/angry_birds.jpg)';
}

function first(){
document.yes.src='http://d.lanrentuku.com/down/png/1205/angrybirds.jpg';
}
function second(){
document.yes.src='http://d.lanrentuku.com/down/png/1110/angry_birds.jpg';
}
//-->
</script>
</head>

<body>
<div id="ok" onMouseover="one()" onMouseout="two()" style="height:150px;width:550px;border:1px solid #ccc;background:#ddd">通过获取id变换</div>
<hr />

<a href="#">
<img src="http://www.baidu.com/img/baidu_jgylogo3.gif" name="yes" onmouseOver="first()" onmouseOut="second()" border="0" />
</a>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  name js id
相关文章推荐