0
$(document).on('change','#id1,#id2,#id3', function(){
       //run my code
    });

The above works

below does not

  var ids = ["#id1","#id2","#id3"];

  $(document).on('change', ids , function(){
           //run my code
        });

I also tried to ids.tostring() to see if changing array to string would work.

1 Answer 1

1

Join the array into a string:

var ids = ["#id1","#id2","#id3"];

$(document).on('change', ids.join(','), function(){
    //run my code
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.