Use this and $(this) instead of $(this)[0] in JS