I have a checkbox that when upon checking a div pops up with a message then if the checkbox is unchecked there is another div that pops up with another message. I got this to work decently but when you click the checkbox a couple of times in a row it gets confused and the messages aren't displayed correctly. Any ideas how to make this work better? (I am a noOb in the jquery department so any help is definitely appreciated). Thanks so much!
HTML:
<input type="checkbox" name="chkWishList" id="chkWishList" />Checkbox Label<br />
<div class="message1"><span>Success<small></small></span></div>
<div class="message2"><span>Removed<small></small></span></div>
jQuery:
$(function() {
$(".message1").css("display", "none");
$(".message2").css("display", "none");
$("#chkWishList").click(function() {
if (this.checked) {
$(".message1").fadeIn("fast").fadeOut(4000);
$(".message2").hide();
}
else {
$(".message1").hide();
$(".message2").fadeIn("fast").fadeOut(4000);
}
});
});