Replaced indexOf with jQuery equivalent to fix support for IE8