I'm trying to make one button that has two functions whether it has class in it or not when clicked. So I tried to make javascript code using if else statement. I don't see what the problem is, but the button is not working..
$(document).ready(function() {
$(".btn-ctrl").click(function() {
if ($(".btn-ctrl > span").hasClass("close")) {
function popDown() {
$("#banner").slideDown(400);
$(".btn-ctrl > span").removeClass("close");
}
} else {
function popUp() {
$("#banner").slideUp(400);
$(".btn-ctrl > span").addClass("close");
}
}
})
})
.btn-ctrl is class name for my button and I'm changing the button's design by adding and removing class="close" in span tag. I can't figure out what is causing problem
popUpandpopDownfunctions from your event and call them in yourif / elsestatement. If it doesn't work can you post your HTML ?<button type="button" class="btn-ctrl"><span>POPUP</span>this is my html code for the button