简体   繁体   中英

Why is this URL PArameter not hiding this div with jQuery?

I am attempting to animate a page div, if the URL has "?success=true" attached.

I have tried multiple methods, to no avail (this is currently placed in the footer).

   <script type="text/javascript">

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                results = regex.exec(location.search);
            return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        }
        if (getParameterByName("success") == "true") 
            $("#success-cover").hide(); 
        });
</script>

And I am using it to affect:

<div id="success-cover" class="success-cover">
 <div class="success" id="success"><img class="success-logo" src="images/logo-small-new.png">
 </div>
</div>

Is there something I am missing?

You've got syntax errors in your if statement:

    if (getParameterByName("success") == "true") {
        $("#success-cover").hide(); 
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM