Ramanjjilu Naidu

Ramanjjilu Naidu

  • NA
  • 88
  • 3.7k

Click event is firing in IE

Nov 15 2016 2:10 AM

I have a question where users can select yes or no. I have written a click event which is not firing for the "first time". if I click on div, it works, it also works in Chrome. Below is my code.

$('#rad1').on('click', function () {

var check = $(this).children('label').first();

if (check.hasClass('yestxt')) {

check.removeClass('yestxt').addClass('checked');

 $("#rad2").children('label').first().removeClass('checked').addClass('notxt');

}

else {

check.removeClass('checked').addClass('yestxt');

}

});

$('#rad2').click(function () {

var check = $(this).children('label').first();

if (check.hasClass('notxt')) {

 check.removeClass('notxt').addClass('checked');

 $("#rad1").children('label').first().removeClass('checked').addClass('yestxt');

}

 else {

 check.removeClass('checked').addClass('notxt');

}

});


Answers (2)