How can I use two selectors in a jQuery function, to do the same actions?

后端 未结 2 841
無奈伤痛
無奈伤痛 2020-12-22 13:08

I want to do the same action for two selectors. I need something like this:

$(\"#ddlSuperFuncao or #ddlMeta\").on(\'change\', function () {
     alert(\'Same         


        
相关标签:
2条回答
  • 2020-12-22 13:35

    You can use as following:

      $("#ddlSuperFuncao, #ddlMeta").on('change', function () {
             alert('Same action when I change one div or other');
      }
    

    For more information read it from here.

    0 讨论(0)
  • 2020-12-22 13:42

    Use , to pass multiple selectors

    $("#ddlSuperFuncao , #ddlMeta").on('change', function () {
    
    0 讨论(0)
提交回复
热议问题