I am looking to reveal concealed buttons using JavaScript

I am currently working on a web page that includes a button to display more buttons upon hover. However, I am facing an issue where the hidden buttons do not appear when hovered over. I referred to this solution: . Can anyone provide guidance on why these buttons are not displaying? The snippet seems to work fine. Is there something specific causing the problem? Also, I would like to have the code in separate files.

var flag = false;

$("#botones").mouseenter(function() {
  if (!flag) {
    flag = true;
    $("#resto").show(200, function() {
      flag = true;
    });
  }
}).mouseleave(function() {
  $("#resto").hide(200);
});
* {
  margin: 0px;
  padding: 0px;
}

div#general {
  margin: auto;
  display: grid;
  margin-top: 0%;
  width: 100%;
  height: 100%;
  background-color: #4f6d7a;
}

div#enlaces {
  float: center;
  display: center;
  width: 100%;
  height: 100px;
  background-color: #166088;
}

div#tablas_carpetas {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  height: 1400px;
  background-color: #DBE9EE;
}

div#tablas {
  order: 1;
  position: static;
  background-color: #dfc0c0;
  height: 600px;
  width: 40%;
}

div#carpetas {
  order: 2;
  width: 60%;
  height: 600px;
  background-color: green;
}

@media all and (max-width: 450px) {
  div#tablas_carpetas {
    display: grid;
  }
  div#tablas {
    width: 100%;
    order: 1;
  }
  div#carpetas {
    width: 100%;
    order: 2;
  }
}
<!doctype html>
<html lang="es">

<head>
  <title>Viewer</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" href="index_style_viewer.css">
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="botones.js"></script>
</head>

<body>
  <div id="general">
    <div id="enlaces">
    </div>
    <div id="tablas_carpetas">
      <div id="tablas">
      </div>
      <div id="carpetas">

        <div id="botones" onmouseover="">
          <button id="principal_1">Redes Sociales</button>
          <div id="resto" hidden>
            <button>Facebook</button>
            <button>Twitter</button>
            <button>LinkedIn</button>
            <button>Gooogle</button>
          </div>
        </div>
      </div>
    </div>
    <div id="anuncios">
    </div>
    <div id="pie">
    </div>
  </div>
</body>

</html>

Answer №1

There seems to be an issue with your JavaScript condition. I tested it using jQuery and it worked perfectly.

$(document).ready(function(){
  $("#botones").mouseenter(function(){
    $("#resto").show();
  });
  $("#botones").mouseleave(function(){
    $("#resto").hide();
  });
});
* {
  margin: 0px;
  padding: 0px;
}

div#general {
  margin: auto;
  display: grid;
  margin-top: 0%;
  width: 100%;
  height: 100%;
  background-color: #4f6d7a;
}

... (CSS code continues)

<!doctype html>
<html lang="es">
    <head>
        <title>Viewer</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    </head>
    <body>
        <div id="general">
            ... (HTML code continues)
        </div>
    </body>

</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Does the Apps Script parser JSON.parse() incorrectly remove leading zeros from string object keys?

I am facing an issue with my Apps Script Web App where JSON data is being manipulated when I try to parse it. Specifically, keys with leading zeros are being altered (e.g "0123" becomes "123") during the JSON.parse() function call. It seems like the functi ...

In Vue, the CropperJs image initially appears small, but it returns to its original size after editing

I encountered a peculiar issue while working on a website for image cropping using Vue.js and CropperJs. On the homepage, users can select an image to crop and proceed to the next page where a component named ImageCropper.vue is displayed. Strangely, the c ...

Refresh the information in a bootstrap popover following a successful ajax request

Whenever I click on a specific div, I aim to have a popover appear with a loading label as the initial content, while simultaneously sending an ajax get request to the server to retrieve data. Once the data is received, I wish to update the existing popove ...

Dynamic web page updates from server using an Ajax request

I have a JavaScript client application and an Express.js server. I am looking to update a page on my server with information sent through an AJAX call from my client application. I need the page to be updated in real-time. Here is the code snippet in my ...

Learn how to use Cocos2d 2.1.4 to load text, strings, and JSON in HTML

Struggling to upload a large string to my project to use as a matrix, I've run into issues trying to load a text file or json into my HTML5 project. While I've seen it can be done in 3.0 using cocos2d, I'm wondering if there's a way to ...

The transformation does not occur again when the window is resized

After seeing a question on How to make svg RTL I attempted to make my svg RTL using: transform: translate(100%, 0) scale(-1, 1); However, I noticed that when resizing my browser window, the transform is not properly applied and the line origin shifts ...

How to disable the onChange event in PrimeNG p-dropdown?

I'm currently utilizing PrimeNG's dropdown component. Each option in the list includes an icon that, when clicked, should trigger a specific method. Additionally, I need to execute another method when the onChange event of the dropdown is trigger ...

Testing the selection of dropdown values in Angular2 using unit tests

I have a dropdown menu for selecting countries. It defaults to a pre-selected value, and when the user changes it, they are redirected to the corresponding country page. However, I am facing an issue while trying to unit test the default value in the sele ...

Exploring AngularJS Navigation in Windows 8 App Store Applications

Hello, I recently started learning about developing Windows Store apps. I found a way to incorporate AngularJS into my Windows 8 store app by making some adjustments in the AngularJS library. However, I'm now struggling with implementing AngularJS rou ...

Why isn't this code for hiding the animation and displaying it not functioning properly?

Why isn't this animation from display none to block working properly? The initial code appears as follows, and it functions correctly: $(".box_outer").stop().animate({top: '25px' , opacity: 1}, 100); When I add display: none; to the class ...

Can we split the PHP Photo Gallery into a second page after displaying 12 images?

I recently developed a simple PHP photo gallery for my website that pulls data from a MySQL database. By using a while loop, I am able to display three images (from ID 1 to 3) in a single row, continuing this pattern until a total of 12 images are shown. ...

Is it possible to trigger an event in Laravel prior to the expiration of a user's login session?

To keep track of when a user logs out, I have set up an event that is triggered after clicking the logout button. The code below demonstrates how I store the logout time: <?php namespace App\Listeners; use App\UserTrack; use Carbon\Carb ...

Gorgeous stew, precise match when using the "findAll()" function

Currently, I am utilizing Python (3.5), Selenium (3.6), and Beautiful Soup (4.6) to scrape a website. The code snippet I have implemented to locate a specific HTML tag is as follows: descContainer=descContainers[0].findAll("div", {"class":"userHtml"}) Re ...

The navigation is designed to only show up as I scroll down the page, but ideally it should be visible

I am trying to make the navigation bar appear on page load instead of when I scroll down the page. Currently, I am using this jQuery code: <script type="text/javascript> $(document).scroll(function() { if ($(this).scrollTop() == 20) { ...

Codeigniter's Implementation of AJAX Pagination with JSON Format

How can I implement pagination using ajax and json format in CodeIgniter? I have successfully implemented pagination without ajax, but now I need to load my data using ajax and json. Can someone guide me on how to add pagination in this scenario? Below is ...

Using React and Material UI to create a table filtering system with checkboxes

I'm currently developing a filtering feature using checkboxes for a data display in a project utilizing React and Material-UI. Is there a custom solution available within Material-UI? If not, what steps should I take to achieve this? As I am rel ...

Issue with TypeScript in React Native: Error message stating that objects cannot be used as a React child (specifically found: [object Date])

Every time I attempt to display the contents of hours, I encounter an error that is puzzling to me because it seems to be related to a date object. How can I properly address the following issue : "Objects are not valid as a React child (found: [object D ...

Tabulate the number of items in an array based on the month and

I have received JSON data with dates indicating the creation time of multiple parcels. I want to analyze this data and calculate the total number of parcels created in each month. I am new to this process and unsure about which thread on Stack Overflow can ...

Angular form submission results in receiving an object instead of a simple value

While building a basic Angular form, I am encountering an issue where instead of retrieving the form value upon submission using onsubmit, I am getting an object as the value. Side Note: I have included some sample code for reference. Could you please ad ...

Arrange by alphabetical order using a dropdown menu

I am stuck and need some help! I have a working Itemlist with Angular, but now I want to add sorting by a select-box. It should look something like this: preview Here is a Plunker example: https://embed.plnkr.co/JYF0u9jBbsfyIlraH3BJ/ <div id="ideaLis ...