I am trying to make an image change color to blue and also change the background color to blue when it is clicked inside a div
. However, my code doesn't seem to be working as expected. Is there a more efficient way to apply CSS to elements?
var photo = $('#photo');
var html = $('html');
var bg = $('#bg');
$(photo).on('click', function(){
$(this).hide()
.delay(600)
.fadeIn(300);
$(html, bg).css({
background :'blue'
});
});
html
<div id='bg'>
<img id='photo' src="http://img.pixland.uz/u11878f337693s.jpg" alt="" />
</div>