If-else -help wanted


Could someone help me please… Why the first event handler does not work and second works ok. I am really confused here :confused:

  $('.btn').click(function() {
    If ($('body').hasClass('open')) {
    } else {

    $('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:

If should be lowercase.

Thanks you @JacksonBates and @kevcomedia you quick answers. I will try to do the modifications next time posting code to forum :slight_smile: I got the code working and my random quote machine is almost ready now :smile_cat: