Jquery selector to get all select dropdowns with ID pattern

后端 未结 3 982
抹茶落季
抹茶落季 2021-01-04 21:31

What is the simplest way to iterate through all select drop downs with ID\'s matching a pattern using jquery. for example:


                        
    
提交评论

  • 2021-01-04 21:54

    Try using attribute starts with selector

      $("select[id^='begin_'").each(function(){
      //your stuff
      })
    
    0 讨论(0)
  • 2021-01-04 21:55

    use attribute starts with selector, then use .each() to iterate through them

    $('select[id^=begin_]').each(function(){...})
    
    0 讨论(0)
  • 提交回复
    热议问题