davelf
06-06-2011, 09:53 AM
I have this script to change background image onmouseover:
<html>
<head>
<style type="text/css">
#test {
background-image:url(images/background-2.jpg);
height:1300px;
width:1800px;
}
</style>
<script type="text/javascript">
function changeBgImage (image, id) {
var element = document.getElementById(id);
element.style.backgroundImage = "url("+image+")";
}
</script>
</head>
<body>
<div
id="test"
onMouseOver="changeBgImage('images/background-2.jpg', 'test')"
onMouseOut="changeBgImage('images/background-3.jpg', 'test')">
</div>
</div>
</body>
</html>
How to add some effect like fade for example. I know we can use jquery, the problem is i'm not really understand how to make it work. Example or tutorial should be nice. Thanks a lot:)
<html>
<head>
<style type="text/css">
#test {
background-image:url(images/background-2.jpg);
height:1300px;
width:1800px;
}
</style>
<script type="text/javascript">
function changeBgImage (image, id) {
var element = document.getElementById(id);
element.style.backgroundImage = "url("+image+")";
}
</script>
</head>
<body>
<div
id="test"
onMouseOver="changeBgImage('images/background-2.jpg', 'test')"
onMouseOut="changeBgImage('images/background-3.jpg', 'test')">
</div>
</div>
</body>
</html>
How to add some effect like fade for example. I know we can use jquery, the problem is i'm not really understand how to make it work. Example or tutorial should be nice. Thanks a lot:)