Jquery validation url for string

I am trying to customize a jQuery script to control the appearance of an extended section of a search form. If the search has not been sent, the divone containing the advanced search should remain hidden. But if the search was sent according to the URL containing the string "Search", show the advanced search div.

The problem I see is that no matter what the url always shows #advsearch divthrough fade in. It never returns false. What am I doing wrong? Thank you for your help!

if(window.location.href.indexOf("Search")) {
$('#advsearch').fadeIn()
}
else {
    $('#adv').click(function() {
    $('#advsearch').slideDown()
    });
}
+3
source share
1 answer

, indexOf -1, true.

:

if(window.location.href.indexOf("Search") > -1)

, URL-, pathName, search hash URL-. location.

+7

All Articles