Very new to jQuery, i'm trying to change the font icon class on click and display a drop down. currently it changes the icon and drops down, but when i want it to toggle back the text toggles but the icon stays the same. here is my code:
$(".answer1").hide();
$(".question1").on("click", function(){
$(".answer1").toggle(300);
$(this).find($(".fa")).removeClass('fa-plus').addClass('fa-minus');
});
any advice?
Very new to jQuery, i'm trying to change the font icon class on click and display a drop down. currently it changes the icon and drops down, but when i want it to toggle back the text toggles but the icon stays the same. here is my code:
$(".answer1").hide();
$(".question1").on("click", function(){
$(".answer1").toggle(300);
$(this).find($(".fa")).removeClass('fa-plus').addClass('fa-minus');
});
any advice?
Share Improve this question asked Jan 27, 2015 at 14:15 RickyRicky 871 gold badge4 silver badges14 bronze badges 1- We need to see your HTML code to see what exactly you are trying to change. – Kelderic Commented Jan 27, 2015 at 14:21
2 Answers
Reset to default 3try
$(".question1").on("click", function(){
$(".answer1").toggle(300);
$(this).find($(".fa")).toggleClass('fa-plus fa-minus');
});
Seconds after posting i tried something and it worked, would this be ok to use? it does what i want it to:
$(".question1").on("click", function(){
$(".answer1").toggle(300);
$(this).find($(".fa")).toggleClass('fa-plus').toggleClass('fa-minus');
});