1) It is in principle not a bug, but instead of a method
is better to use
. This way you will have uniformity in the code.
to be stored in a variable, not to create each time an instance of jQuery
also be saved to a variable, because the search in the DOM tree, the most costly operation in scripts.
4) Use a chain of calls in full, and not partially as it is now.
5) Some extra code you have written, I don't know what it's for.
In the end your code will look like this: https://jsfiddle.net/beLsd91g/1/