I seem to be struggling with hiding/showing a div element. Can you figure

I am in the process of creating a gallery that will display a div with images when a button is clicked.

The issue I am facing is that when I have two buttons, only the last images are clickable. It's a bit difficult to explain, but you can see it in action on my website:

Is it incorrect to have two scripts like this?

Script 1:

<script type="text/javascript">
 $(document).ready(function(){
    $(".slidingpriv").hide();
    $(".show_priv").show();
    $('.show_priv').click(function(){
    $(".slidingpriv").slideToggle();
    });

});

Script 2:

<script type="text/javascript">


$(document).ready(function(){    
    $(".slidinggf").hide();
    $(".show_gf").show();
    $('.show_gf').click(function(){
    $(".slidinggf").slideToggle();
    });    
});

HTML:

<div class="row">

<div class="container">

        <!---section--->

        <div class="center">
        <a href="#show_priv" class="show_priv">Private projects</a>
        </div>
        <div class="slidingpriv">

        <a href="pages/inasecond/inasecond.html"><div id="imgstyle" class="image"> 
        <img href="" src="img/inasecond.jpg" width="300" height="300"  alt=""/></a> 
        </div>

        <a href="pages/2012/2012.html"><div id="imgstyle" class="image">
        <img src="img/2012.jpg" width="300" height="300"  alt=""/> </div></a>

        <a href="pages/greenlights/greenlights.html"><div id="imgstyle" class="image">
        <img src="img/Cover-text.jpg" width="300" height="300"  alt=""/> </div> </a> 

        </div>

        <!---section--->

        <div class="center">
        <a href="#show_gf" class="show_gf">Grundforløb</a>
        </div>

        <div class="slidinggf">

        <a href="pages/inasecond/inasecond.html"><div id="imgstyle" class="image"> 
        <img href="" src="img/inasecond.jpg" width="300" height="300"  alt=""/></a> 
        </div>

        <a href="pages/2012/2012.html"><div id="imgstyle" class="image">
        <img src="img/2012.jpg" width="300" height="300"  alt=""/> </div></a>

        <a href="pages/greenlights/greenlights.html"><div id="imgstyle" class="image">
        <img src="img/Cover-text.jpg" width="300" height="300"  alt=""/> </div> </a> 

        </div>

CSS:

    .center{
    position:relative;
    width:100%;
    height:100%;
    margin:0 auto;
    text-align:center;
    /*background-color:#0C3;*/
}    
    .show_priv {
    display:none;
    position:relative;
    height:100%;
    /*background-color: #99CCFF;*/

}

    .slidinggf {
    height:100%;
    /**background-color: #99CCFF;**/
    width:100%;
    position:relative;
}

    .show_gf {
    display:none;
    position:relative;
    height:100%;
    /*background-color: #99CCFF;*/
}
    .slidingpriv {
    height:100%;
    /**background-color: #99CCFF;**/
    width:100%;
    position:relative;
}

Thank you! ;)

Answer №1

One effective way to troubleshoot browser issues is by utilizing the developer tools available in your browser. These tools are user-friendly and can help you easily debug problems, such as using the inspect element feature.

To access these developer tools:

Visit Chrome Developer Tools

Explore Mozilla Developer Tools

The developer tools can assist you in identifying elements that may be causing obstacles in terms of clickable functionality, even when you believe everything should be working correctly.

Additionally, consider consolidating scripts within the same document (e.g., $(document).ready(function(){});) for smoother execution.

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

Add HTML content to an element within a directive and create a custom function to manipulate it locally

In my AngularJS application, I am faced with a variety of complex inputs scattered throughout. Some inputs utilize directives for autocompletion functionality, like those powered by Google Places or Twitter Bootstrap. I am currently exploring the concept ...

"Exploring the variations in design between wordpress.com and self-hosted wordpress

I'm currently puzzling over the source of the disparities in style between my Wordpress site hosted elsewhere and my identical theme on Wordpress.com. It's perplexing to see such contrasting appearances while I migrate my blog. After some irrele ...

Retrieve an array object containing specific properties using axios

Currently, I am retrieving JSON data from an API call using axios and displaying it through Vue. This snippet shows the JSON Object logged in the console: 0: category_id: "categ1" item_name: "item1" price: 100 stock: 155 1: c ...

Generate CANNON.RigidBody using either a THREE.Mesh or THREE.Geometry object

For my project, I am using a THREE.JSONLoader to create a THREE.Mesh object as shown below: // Creating a castle. loader.load('/Meshes/CastleTower.js', function(geometry, materials) { var tmp_material = new THREE.MeshLambertMaterial(); T ...

Tips for closing two nested Material-UI popovers when a button is clicked or when clicked elsewhere

Trying to create a menu with nested popovers from Material-ui has presented a challenge. I want all the popovers to close when I click on a menu option, rather than having to close them individually. Additionally, it would be more user-friendly if the popo ...

row-1 css classes on the top in a project built with Blazor

I'm currently working on customizing the standard layout provided in Blazor projects like WASM or server, but I'm a bit perplexed by the top-row px-4 css classes. Within the HTML code that appears to define the top row/header section is this sni ...

Creating a dynamic circle that expands in size based on the duration the user presses down (using Java Script)

I have a fun challenge for you! I want to create a growing circle on a canvas based on how long you hold your mouse button. Currently, I can draw a fixed width circle where my mouse was when I clicked, but I need it to dynamically change size as you hold t ...

Converting JSON data into objects in JavaScript

My task involves processing a large JSON list with over 2500 entries, formatted as follows: [ ['fb.com', 'http://facebook.com/'], ['ggle.com', 'http://google.com/'] ] This JSON list represents pairs of [&ap ...

Is there a way to identify if the parent page has completed loading while within an iframe?

Is there a way to detect properties or events within the iframe that can help determine this? The src of the iframe and the parent page belong to different domains. ...

Encountering an issue while trying to execute the pagination page demo in PHP?

<?php include("include/db.inc.php"); $sql = mysql_query("SELECT * FROM emp"); $nr = mysql_num_rows($sql); if(isset($_GET['page'])){ $pn = preg_replace('#[^0-9]#i','',$_GET['page']); ...

Steps for instructing Google Maps to identify the location of a provided Google Maps URL

Is it possible to extract longitude and latitude data from a shared URL and place them into a marker? For example, users might copy and paste the 'Share' URL from Google Maps. For instance: or Direct Location: https://www.google.co.nz/maps/plac ...

Error Encountered in Jhipster Application During Initial Launch

Struggling with running a newly generated Jshipster 3 application using gulp serve after successful generation. My setup includes Ubuntu 16.04 and npm 3.9, but I keep encountering an error when attempting to execute gulp serve: check out this screenshot ...

The FlatList component will only trigger a re-render once the list has been scrolled

I need help with updating a FlatList in my app. Currently, the list is populated by an array stored in the component's state and can be filtered using a filtering function that updates the state with a new filtered array. However, I have noticed that ...

The average calculation malfunctioning after adjusting the input data

I am a beginner with AngularJS and facing an issue. I have a list of cities for which I need to calculate the average temperature. However, after editing the temperature values in the city list, the function that computes the average temperature is giving ...

Recreated using CSS and JavaScript: iOS "Background Open" Animation

I am currently seeking a method to replicate the iOS Safari animation that occurs when opening a link in the background (the item jumps up and quickly animates to where it can be accessed) - This same animation is also seen on OSX Safari's "save to re ...

Using AngularJS to integrate a function within a component

Hey there, I am facing an issue trying to call a function that is in a component. Let me share the code snippet from my component buttonsController: (function(){ "use strict"; angular .module('my') .component('myButton&ap ...

What other technique can I use to replace the creation of a jquery division?

I`m relatively new to all things related to web technologies and I am currently practicing and learning about them. On my practice page, I've experimented with various elements, including changing div heights based on the viewport height. Here's ...

Can we pause and resume the progress bar using Javascript in conjunction with animationPlayState?

Looking for a way to control a progress bar script that runs for 180 seconds and then redirects the browser? Check out the code snippet below. I've added an onclick event to test pausing the progress bar. My goal is to pause, reset, and adjust the dur ...

Methods for altering the color of a div using addEventListener

Why doesn't the color change when I click on the div with the class "round"? Also, how can I implement a color change onclick? var round = document.querySelector(".round"); round.addEventListener("click", function() { round.style.backgroundCol ...

The function correctly identifies the image source without error

I possess a pair of images: <img id="img1" src="l1.jpg" usemap="#lb" height="400" border="0" width="300"> <img src="images.jpg" id="img2"> Next up is some JavaScript: function validateImages () { if (document.getElementById('img2&ap ...