如何设置jQuery以排除函数中的类? [英] How do set up jquery to exclude classes in a function?

查看:66
本文介绍了如何设置jQuery以排除函数中的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上只了解如何读取JavaScript并进行修改.

I essentially only understand how to read bits of JavaScript and make modifications.

我正在使用我购买的脚本grid-slider,但是代码编写者目前是mia,所以希望这里有人可以帮助我.

I am using grid-slider, a script I purchased, but the code writer is mia at the moment, so hopefully someone here can help me.

基本上,它是一个滑块,并且有一些选项可以像正常一样打开链接,也可以在同一页面的面板中打开链接.我希望某些链接在面板中打开,而另一些链接在父窗口中打开.

Basically, it's a slider and there are options to have links open like normal or to have links open in a panel on the same page. I want some links to open in a panel and others to open in the parent window.

在我看来,完成此操作所需要做的就是激活面板显示功能(已完成),然后设置排除功能以排除某些ulli与功能中的特定类.我已经读过有关.not选择器的信息,但是我看不出如何使它适用于以下代码:

It seems to me that all that would be required to do this would be to activate the panel display function (which I've done) and then set up an exclude function to exclude certain uls or lis with a specific class from the function. I've read about the .not selector, but I don't see how to make it applicable to this code:

else {
    if (this._displayOverlay) {
        if ($item.find(">.content").size() > 0) {
            $item.data("type", "static");
        }
        else {
            var contentType = this.getContentType($link);
            var url = $link.attr("href");
            $item.data({type:contentType, url:(typeof url != "undefined") ?  url : ""});
        }
        $item.css("cursor", "pointer").bind("click", {elem:this, i:i}, this.openOverlay);
    }
    $link.data("text", $item.find(">div:first").html());
    $img = $link.find(">img");                      
}

任何人都可以基于此提供帮助吗?在 此处 .

Can anyone help based on looking at this? There is a link to the demo of the code in here.

谢谢.

推荐答案

请参阅jQuery文档 .not() 方法从匹配元素的子集构造一个新的jQuery对象.因此,您可以在要排除的位置(在这种情况下为您的类)应用于事件的.not(),例如,排除要绑定的类('click'):

Referring to the jQuery documentation .not() method constructs a new jQuery object from a subset of the matching elements. So you can apply .not() where you want exclude, in this case your class, to an event, for example exclude a class to bind('click'):

$item.css("cursor", "pointer").not('.myexcludedcalss').bind("click", {elem:this, i:i}, this.openOverlay);

(如上面的评论中所述)

(like mentioned in the comment above)

这篇关于如何设置jQuery以排除函数中的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆