문제

I want to hide the slider (and a bit more) if someone uses the search module on my Joomla site and tried several solutions mentioned here on stackoverflow like: https://stackoverflow.com/a/1760605/1641903

Currently my code looks like this:

<script>
if (/\/search\//.test(window.location)) {
    $('#hideonsearch').hide();
}
</script>

I wrapped the slider in <div id="hideonsearch> and tried mentioned jquery in both the body and head (just to be sure), but it doesn't seem to work as you guys can see here.

Any idea on how to get in working?

도움이 되었습니까?

해결책

I saw in your web site that the jquery is not loaded when your code is being executed.

You must put your code in the "onload" function, or make sure the jquery is loaded before doing this.

window.onload = function () {
    if (/\/search\//.test(window.location)) {
        jQuery('#hideonsearch').hide();
    }
};

Or you can use the pure javascript code that is better.

window.onload = function () {
    if (/\/search\//.test(window.location)) {
        document.getElementById("hideonsearch").style.display = "none";
    }
};

I saw another error in your web site now, related to this code:

jQuery(document).ready(function(){
    jQuery('.hasTooltip').tooltip({"html": true,"container": "body"});
});

error:

undefined is not a function

And it is related to the same problem, jQuery is not loaded, so you can use "window.onload".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top