Jquery change background color

The .css() function doesn’t queue behind running animations, it’s instantaneous. To match the behaviour that you’re after, you’d need to do the following: The .queue() function waits for running animations to run out and then fires whatever’s in the supplied function.

Check if element exists in jQuery

$(‘elemId’).length doesn’t work for me. You need to put # before element id: With vanilla JavaScript, you don’t need the hash (#) e.g. document.getElementById(‘id_here’) , however when using jQuery, you do need to put hash to target elements based on id just like CSS.