1

I have some dropdown lists appended by jquery after a ajax request to the page. All of them has class counter. Now I want to set a change function for them but its not working at all. My jquery version is 1.9.1. I tried these:

$(".counter").on("change",function () {
    alert("ok");
});

And

$(".counter").change(function () {
    alert("ok");
});
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
Hamid Reza
  • 2,913
  • 9
  • 49
  • 76

1 Answers1

1

Your content added dynamically so you have to use jQuery on for dynamic content.

$(document).on("change",".counter",function () {
    alert("ok");
});

For jQuery 1.7+ you can attach an event handler to a parent element using .on(), and pass your class selector combined with 'document' as an argument.

See http://api.jquery.com/on/

Sadikhasan
  • 18,365
  • 21
  • 80
  • 122