Question

I'm using jquery 1.6.1.When I want to use addClass with live change, it doesn't work. please look at my example: http://jsfiddle.net/mr_seven/Mp8zc/1/

$("#qty").live('change', function() {
    if ($(this).val() == '1'){
        jQyery('#card_2').addClass('takhfif');
    } else {
        jQyery('#card_2').removeClass('takhfif');
    }
});
Était-ce utile?

La solution

you have typo for selector. it should be jQuery not jQyery:

$("#qty").live('change', function() {
 if ($(this).val() == '1'){
     jQuery('#card_2').addClass('takhfif');
  } else {
     jQuery('#card_2').removeClass('takhfif');
 }});

Working Fiddle

Autres conseils

This should be jQuery not jQyery:

$("#qty").live('change', function() {
  if ($(this).val() == '1'){
    jQuery('#card_2').addClass('takhfif');
  } else {
     jQuery('#card_2').removeClass('takhfif');
  }
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top