Improved coding

Conformed to better standards: creating a variable $this when using
$(this) multiple times, using throw new Error instead of console.log,
and removing redundant checks that I or jQuery is already doing.