Any one can tell me please, what is the different between this three things.
if ( document.location.href.indexOf('#Work') > -1 ) {
$('#elementID').animate({"left": "250"}, "slow");
}
if ( document.location.href.indexOf('#Work') > 0 ) {
$('#elementID').animate({"left": "250"}, "slow");
}
if ( document.location.href.indexOf('#Work') != -1 ) {
$('#elementID').animate({"left": "250"}, "slow");
}
The “IndexOf” method will return the integer of location where a string was found within it’s parent.
In this case, “#Work” within document.location.href
“> -1” Returned when string is found.
“> 0” Returned when string is found after the first char
“!= -1” Returned when string is found, regardless of place (same as #1)
BTW – This is core Javascript and not Jquery.