如果Div不存在则jQuery [英] jQuery If Div Does NOT Exist
问题描述
我有3个图像并且具有一个功能,因此在鼠标翻转时它们会淡入淡出。如果被翻转的图像具有已选择类,我不想这样做。
I have 3 images and have a function so that on mouse rollover they fade in and out. I don't want to do this if the image being rolled over has the class 'selected'.
到目前为止,我有这样的代码:
So far I have this code:
$(".thumbs").hover(function(){
if (!($(this).hasClass(".selected")){
$(this).stop().fadeTo("normal", 1.0);
},function(){
$(this).stop().fadeTo("slow", 0.3);
}
});
对我来说,IF语句看起来应该是:
to me the IF statement looks like it should be:
if (!($(this).hasClass(".selected"))){
但是都不起作用所以谁知道。当我实现这个代码时,我的整个javascript停止工作,任何想法为什么?
but neither work so who knows. When I implement this code my entire javascript stops working, any ideas why?
几乎没有关于谷歌jQuery的IF语句的信息,这太荒谬了。我非常感谢任何帮助!
There is virtually NO information on IF statements for jQuery on Google, it's ridiculous. I would greatly appreciate any help!
推荐答案
选择器上的jQuery文档告诉你所需要的一切知道。
The jQuery docs on selectors tells you everything you neeed to know.
$('.thumbs:not(.selected)').hover(function(){
// ...
})
这篇关于如果Div不存在则jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!