Rosh_LK
Rosh_LK

Reputation: 700

Show a menu item after site fully loaded

I need to show a change language menu item after my Wordpress site is fully loaded. I edited the menu item css into my menu item:

.my-menu-item {
    visibility: hidden;
}

and in my functions.php file i added as follows:

add_action( 'wp_loaded', 'menushow', 99 );      

function menushow() { ?>
    <script type='text/javascript'>
        /* <![CDATA[ */
        jQuery(window).load(function() {
            // When the page has loaded
            jQuery(".my-menu-item").css("visibility", "true");
        });
        /* ]]> */
    </script>
<?php }

but the problem it's not working. Please help me out here...

Upvotes: 3

Views: 442

Answers (3)

user5122725
user5122725

Reputation:

Use this:

jQuery(window).load(function($) {

instead of

jQuery(window).load(function() {

If it doesn't work, try to make a separate script file, put your code into it and attach that script file to your theme.

Upvotes: 0

AlexG
AlexG

Reputation: 5919

As stated before you can use .show();, but as far as I know you have to give it the default value display: none; to work.

The Style visibility: true; does not exist, try visibility: visible; More information here!

Upvotes: 2

P. Frank
P. Frank

Reputation: 5745

use .show()

jQuery(".my-menu-item").show();

Upvotes: 1

Related Questions