【问题标题】:Ignoring certain variables in a jquery忽略 jquery 中的某些变量
【发布时间】:2015-01-05 16:02:13
【问题描述】:

steam 吸墨纸页面(包含活动和其他内容的页面)和 javascript 中有一个 javascript 代码:

(function() { 
    jQuery(".btn_grey_grey.btn_small_thin.ico_hover").map(function(){
        this.click()
    });
})(). 

我希望它忽略“btn_grey_grey.btn_small_thin.ico_hover.active”,只点击 btn_grey_grey.btn_small_thin.ico_hover。有可能这样做吗?当前代码单击活动按钮和非活动按钮。双引号似乎没有任何改变。

【问题讨论】:

  • 使用:not() 选择器
  • 为什么要用map()循环点击?
  • 对不起,我上周才开始学习 JavaScript,我还不是很擅长。未来我会做得更好。

标签: javascript jquery steam


【解决方案1】:

使用:not 选择器和each 代替map(用于不同目的):

jQuery(".btn_grey_grey.btn_small_thin.ico_hover:not(.active)").each(function() {
    this.click();
});

还请注意,如果您使用 jQuery 绑定事件处理程序,您可以尝试更简单的表达式:

jQuery(".btn_grey_grey.btn_small_thin.ico_hover:not(.active)").click();

【讨论】:

    猜你喜欢
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 2013-06-10
    • 2019-03-15
    • 2014-11-03
    • 1970-01-01
    • 2014-07-09
    相关资源
    最近更新 更多