Reputation: 111
When Mouse over To div selector I want to bring the background image to the div in jquery. Here I am facing problem in anchor tag. In anchor tag I called the image.so when I mouse over to img attribute ,The jquery image is not visible , Instead of image if I give text , the jquery brings the background image to the div.You can see my code
Here is my html:
<div class="productnew">
<a href="#"><img src="img/dynamic/girlsproduct-01.png" ></a>
</div><!--end of productnew-->
Here is my jquery:
$(function()
{
$('.productnew').hover(function(){
//alert('ok');
$('.productnew').css('background-image','url("img/dynamic/boysproducts-01.png") no-repeat');
});
});
Upvotes: 0
Views: 34
Reputation: 123
Try it : Change your jquery code as per below ... may be it help to you
$(function()
{
$('.productnew').mouseover(function () {
//alert('ok');
$('.productnew a img').attr('src', 'img/dynamic/boysproducts-01.png');
});
$('.productnew').mouseout(function () {
//alert('ok');
$('.productnew a img').attr('src', 'img/dynamic/girlsproduct-01.png');
});
});
Upvotes: 1