我无法理解下面的脚本 [英] I can't understand the following script
本文介绍了我无法理解下面的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于我是jQuery的新手,我发现这个脚本对我的项目很有用。我想淡化容器内的图像。
< script type =text / javascript>
$(document).ready(function(){
$(#collage-container img)。mouseover(function(){
$(#collage-container img) .css(z-index,1);
$(this).css(z-index,999);
$(this).fadeOut(100,function(){$ (this).fadeIn(1000);});
});
});
< / script>
很难理解第4行和第5行。第5行是图像吗?
解决方案中的
$(this)
是 $( #collage-container img)
,你可以像下面那样重写你的代码。顺便说一下,line4没有选择,它将z-index设置为1,但是第5行再次将z-index设置为999. $(#collage-container img)。 ,999).fadeOut(100,function(){
$(this).fadeIn(1000);
});
});
});
As I'm new to jQuery I found this script which is useful for my project. I want to fade the image inside the container.
<script type="text/javascript">
$(document).ready(function(){
$("#collage-container img").mouseover(function(){
$("#collage-container img").css("z-index",1);
$(this).css("z-index",999);
$(this).fadeOut(100,function(){ $(this).fadeIn(1000); });
});
});
</script>
It's hard to understand line 4 and 5. Is line 5 the image?
解决方案
The $(this)
in the callback function is $("#collage-container img")
, you could rewrite your code like below . By the way, line4 has no sence, it set the z-index to 1, but line 5 set z-index again to 999.
$(document).ready(function () {
$("#collage-container img").mouseover(function () {
$(this).css("z-index", 999).fadeOut(100, function () {
$(this).fadeIn(1000);
});
});
});
这篇关于我无法理解下面的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文