您现在的位置是:首页 > 电脑技术查询 > web开发

小小的js代码解决思路

编辑:chaxungu时间:2022-10-02 23:18:21分类:web开发

小小的js代码
写一个图片的onmouseup的事件函数
点那张图片
div层的背景就边换成那张图片

------解决方案--------------------
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> new page </title>
<script>
function aaa(obj){
document.getElementById( "div1 ").style.backgroundImage= "url( "+obj.src+ ") ";
}
</script>
</head>
<body>
lz自己加下图片的路径 <br>
<img src= "# " onclick=aaa(this)> </img>
<div id=div1> 这里是div </div>
</body>
</html>