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

查看:16
本文介绍了如何设置 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.

在我看来,这样做所需要做的就是激活面板显示功能(我已经这样做了),然后设置一个排除功能来排除某些 ullis 具有来自函数的特定类.我已经阅读了 .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天全站免登陆