我想创建一些东西,当点击div
元素内的图像。它应该将其颜色更改为蓝色,并将背景颜色更改为蓝色。我写的代码是否正确?因为它不能正常工作。另外,有没有更好的方法来将CSS应用到元素上?jQuery的CSS属性选择
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>
的可能重复[如何运行两个jQuery的动画同时?](http://stackoverflow.com/questions/1251300/how-to-run-two-jquery-animations-simultaneously) – Vucko
看到这个工作正常http://jsfiddle.net/Fagc9/1/ –
@ ShekharPankaj不工作!!!! – Tukhsanov