Вопрос

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