show div only if meta tag exists

I have an include file that is used in different applications and different platforms.

I want to show a div below

    <div id="my-menu" class="dropdown"></div>

only if there is a meta tag – its hidden via display:none by default in the css

the meta tag would be something like this

    <meta name="login-menu" content="show"/>

if they add the above meta on their applications i want show #my-menu div.

what is the best way to do this via jquery?, here is a start

   if ($('meta[name="login-menu"]').attr('content')) {
       $( "#my-menu" ).show();


You should check the length to see if it exists:

if ($('meta[name="login-menu"]').length) {
    $( "#my-menu" ).show();

Leave a Reply

Your email address will not be published. Required fields are marked *