【问题标题】:how can i get all inputs excluding buttons and hidden fields with jquery?如何使用 jquery 获取除按钮和隐藏字段之外的所有输入?
【发布时间】:2011-02-28 17:36:06
【问题描述】:

我有以下将排除所有按钮,但我怎样才能排除隐藏字段?

$("#selector").find(":input:not(:button)").each(function (i) { // do something

我确定这可能很简单,我就是找不到。

非常感谢!

【问题讨论】:

    标签: jquery jquery-selectors css-selectors


    【解决方案1】:

    对我来说,(jquery 2.2.0)

    没有工作

    $('#signup-form :input:not(:hidden :button)').each(function(){
    $('#signup-form :input').not(':hidden :button').each(function(){
    $('#signup-form *').filter(':input:not([type=hidden][type=button])').each(function(){
    

    确实

    $('#signup-form *').filter(':input').not(':button').not('input[type=hidden]').each(function(){
    

    $('#signup-form :input').not(':hidden').not(':button').each(function(){
    

    【讨论】:

      【解决方案2】:

      下面的代码应该可以做到。

      $('#selector :input').not(':button,:hidden').each(...);
      

      【讨论】:

        【解决方案3】:
        $("#selector :input:not(:button, :hidden)").each(function (i) { // do something
        

        【讨论】:

          【解决方案4】:
          $('#selector').find('input').not(':button').not('input[type=hidden]').each(function(i) {
          });
          

          应该这样做。 不知道是不是这个

          $('#selector').find('input').not(':button').not(':hidden').each(function(i) {
          });
          

          也适用于此目的,但值得一试。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2019-05-18
            • 1970-01-01
            • 2016-08-14
            • 2015-04-17
            • 2022-01-01
            • 1970-01-01
            • 2018-02-07
            • 2016-07-31
            相关资源
            最近更新 更多