Reputation:
To configure a burger navigation, I'm trying to perform 2 changes from one condition. I'm getting the following error :
SyntaxError: missing : in conditional expression
My code is as follows :
$(".burger").on("click", function() {
"20px" == $(".main-navigation").css("left") ? $(".navbarWrap").css("z-index", "-1"), $(".main-navigation").animate({
left: "100%"
}, 200) : $(".navbarWrap").css("z-index", "1"), $(".main-navigation").animate({
left: "20px"
}, 200)
})
Any idea where my error is ? Thanks
Upvotes: 0
Views: 72
Reputation: 36703
$(".burger").on("click", function() {
"20px" == $(".main-navigation").css("left") ? ($(".navbarWrap").css("z-index", "-1"), $(".main-navigation").animate({
left: "100%"
}, 200)) : ($(".navbarWrap").css("z-index", "1"), $(".main-navigation").animate({
left: "20px"
}, 200))
});
You need to wrap the if else outputs in ()
Upvotes: 1