could someone please guide me with this piece of codes. Currently when i mouseover a link, it change the background color on another div. Instead of changing the background color, I'd like to change to another background image.
<html>
<head>
<title>Sample</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<style>
body {
background: #ccc;
transition:0.5s;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$("#div-1").hover(
function () {
$('#top_section').css("background", "#ff9900");
},
function () {
$('#top_section').css("background", "#ccc");
}
);
$("#div-2").hover(
function () {
$('#top_section').css("background", "red");
},
function () {
$('#top_section').css("background", "#ccc");
}
);
$("#div-3").hover(
function () {
$('#top_section').css("background", "yellow");
},
function () {
$('#top_section').css("background", "#ccc");
}
);
});
</script>
</head>
<body>
<a id="div-1" href="#"> Orange</a>
<a id="div-2" href="#">Red</a>
<a id="div-3" href="#">Yellow</a>
<div id="top_section" style="height:100px;width:100px;"></div>
</body>
</html>
I was changing the line $('#top_section').css("background", "#ff9900"); to $('#top_section').css("background-image", "/images/image1.jpg"); but nothing happen when i mouse over the link.
thank you very much,
.css("background-image", "/images/image1.jpg");to.css("background-image", "url('/images/image1.jpg')");