Sorry if this is a repeat but couldnt find anything the same ish…
I can’t get the if else statement to work. I get the first part done but the second won’t.
The aim is to click on a div and it expands, then when clicked again it shrinks.
$(document).ready(function(){
if($(".back2").css("height") < "51px")
{
$(".back2").click(function()
{
$(".back2_img,.back2").css({"height":"200px"}, 'slow');
});
}
ElseIf($(".back2").css("height") >"55px")
{
$(".back2").click(function()
{
$(".back2,.back2_img").css({"height":"50px"}, 'slow');
});
};
});
I’ve tidied up your code, also it is
else ifnotElseIf.You also had a slight syntax problem with one of your
;. (Not necessarily a code breaking error, but just a good habit to keep things 100% consistent, see comments for more info).Proper nesting of code will save you hours of headache!