I'm trying to shorthand my jQuery now that I have my working script and i'm doing (where necessary) inline IF statements to shorten code. Only issue is i'm trying to do so without using an ELSE statement as it is not required, but this is just throwing me an error.
jQuery IF Statement
(conH > sliderH ? ($(".sliderDownDisabled").addClass("sliderDown") $(".sliderDown").removeClass("sliderDownDisabled")));
The error in the error console is telling me I missing parentheses, which I'm not as i have checked through the line and all the matching parentheses are correct. I don't know where I am going wrong and if anybody could point me in the right direction that would be great.
Solution
(conH > sliderH && ($(".sliderDownDisabled").addClass("sliderDown") && $(".sliderDown").removeClass("sliderDownDisabled")));
By adding the &&
in place of the ?
selector and inbetween the two pieces of code I want to be executed I have obtained the desired results.