Nate Pet
Nate Pet

Reputation: 46222

jQuery checkbox onChange

I have a checkbox with an id of activelist

I tried the following but did not seem to work (I have below in) :

$(document).ready(function () {
  $('#activelist :checkbox').change(function () {
    alert('changed');
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" id='inactivelist' value="inactivelist" />

Upvotes: 36

Views: 173187

Answers (3)

arul pushpam
arul pushpam

Reputation: 561

$('input[type=checkbox]').change(function () {
    alert('changed');
});

Upvotes: 7

mgraph
mgraph

Reputation: 15338

There is no need to use :checkbox, also replace #activelist with #inactivelist:

$('#inactivelist').change(function () {
    alert('changed');
 });

Upvotes: 54

Sparkup
Sparkup

Reputation: 3754

There is a typo error :

$('#activelist :checkbox')...

Should be :

$('#inactivelist:checkbox')...

Upvotes: 6

Related Questions