Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9084115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:55:39+00:00 2026-06-16T20:55:39+00:00

I am making a script to make a submenu visible as a dropdown when

  • 0

I am making a script to make a submenu visible as a dropdown when the menu button is hovered (or onmouseover). I made the if condition refer to this.id=”menutoggle1″ and check if it’s true or false.

If true, it should fire off a function with the statement

document.getElementById("submenu1").style.display="inherit";

It doesn’t work, but I assume this has something to do with my if condition. I don’t really understand conditions that well, but I hope someone can explain why this is wrong, and maybe even help me fix it.

This is my code;

function submenu_show()
{
  if(this.id="menutoggle1" == true)
  {
    document.getElementById("submenu1").style.display="inherit";
  }
}

I know another way that I can achieve the result I want, but then I need to write two functions to show and two functions to hide, for all the menu options that are supposed to have submenus, and it is just messy and ugh.

EDIT: I figured I couldn’t make it work without dropping my idea completely, so I just went with the other alternative. I also realized that wasn’t really that messy after all, when written properly (it is supposed to be used for several drop downs after all).

Here’s the code I used eventally;

<div id="menubutton1" onmouseover="submenu1_show();" onmouseout="submenu1_hide();"></div>
<div id="submenu1" onmouseover="submenu1_show();" onmouseout="submenu1_hide();"></div>

function submenu1_show()
{document.getElementById("submenu1").style.display="inherit";}
function submenu1_hide()
{document.getElementById("submenu1").style.display="none";}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:55:40+00:00Added an answer on June 16, 2026 at 8:55 pm

    In the current code, this is merky. Its certainly not the element’s ID. You could find the element in the function.

    function fnName(){
         var el = document.getElementById("...");
         if(el.id === "something"){ ... }
    }
    

    If you want to get the function to do this for a particular ID, you could just add a param to the fnName function and pass that param do the doc.getElByID function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make search terms bold in this search script that I'm making.
I am making a tiny script to make a HTML element editable. When you
I'm making a script that parses an xml and outputs a html form. This
I am making a script to help make it easier to import products into
I have been making a script to display users and make changes to their
I cannot seem to figure out what is making this script go wrong... You
I am trying to make a script that dynamically generates world chunks by making
I use this wonderful script to make my table sortable and add some filters
I'm trying to make my life easier by making a script that generates HTML
How do i make a href link call upon a PHP script without making

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.