Hi,
Could someone help me please… Why the first event handler does not work and second works ok. I am really confused here
$(function(){
$('.btn').click(function() {
If ($('body').hasClass('open')) {
$('body').removeClass('open');
} else {
$('body').addClass('open');
}
})
})
$(function(){
$('.btn').click(function(){
$('body').hasClass('open') ? $('body').removeClass('open'):$('body').addClass('open')
})
})
Capitalized If
, should be if
.
Also, formatting your code makes it easier to spot errors on the forum. I did it for you this time, but you can do it yourself like this:
This post is modeled on http://forum.freecodecamp.com/t/markdown-code-formatting/18391, but modified for the slight differences between the Forum and Gitter. If you are interested in using Spoiler blocks, check this post: Spoilers. You can post code...
Reading time: 2 mins 🕑
Likes: 42 ❤
Thanks you @JacksonBates and @kevcomedia you quick answers. I will try to do the modifications next time posting code to forum I got the code working and my random quote machine is almost ready now
-Zumi-