Guide to updating the content of a div by selecting a button located outside the div

Thank you for taking the time to go through this post. I hope that those with similar questions will find their answers as well.

Currently, I am in the process of developing a single-page website that is divided into 8 large divs. The concept is such that when you click on the menu bar, it navigates you to one of these divs or "pages".

One particular section of my website acts as an introduction and I am attempting to incorporate this captivating effect: http://jsfiddle.net/unbornink/LUKGt/

In this segment, there is a row of buttons labeled "Who we are", "What we do", "How we think" and more. Below this button row, there is a div where different texts are displayed upon clicking various buttons.

I followed all the steps outlined here:http://jsfiddle.net/unbornink/LUKGt/. Regrettably, I have been unsuccessful in making the buttons function as intended.

Below is a snippet of the code I've been working on:

<head>    
<link href="textContainer.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<style type="text/css">   
.textWord_about{
position: absolute;
font-family: Calibri;
font-size: 14px;
top: 22px;
left: 29px;
width: 650px;
height: 390px;
text-align: left;
background-image: url(images/slider_bkgd.png);
background-repeat: repeat;
}
.textContainer_about {
position: absolute;
top: 870px;
left: 234px;
width: 727px;
height: 452px;
z-index: 20;
color: rgb(4,4,4);
display: block;
background-image: url(images/slider_bkgd.png);
background-repeat: repeat;
overflow: visible;
}
.links {
font-family: Calibri;
font-size: 14px;
}
</style>
</head>

<body>
<div id="menu_about">
...

Your assistance in resolving this issue would be highly appreciated! Thank you in advance!


Answer №1

There seems to be a typo in the selector. Please update textword_about to textWord_about [Make sure to note the uppercase letter W in textWord_about]

Code Correction: http://jsfiddle.net/LUKGt/5/ (excluding your stylesheets)

Updated Code:

$('.textWord_about').hide();

$('.link').click(function() {
    $('.textWord_about').hide();
    $('.textWord_about[data-link=' + $(this).data('link') + ']').fadeIn({
        width: '200px'
    }, 300);
});​

Answer №2

If your desired audience is using browsers that support the :active pseudo class, you may not need to rely on JavaScript for this.

Pure CSS Variant

Answer №3

One key observation or potential oversight may be:

It appears that you are utilizing 'textword_about' in your HTML code, while using 'textWord_about' in your JavaScript.

Consider ensuring consistency by using the same naming convention for both the HTML and JavaScript implementations.

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

Error message: When using the Semantic UI React Modal, the Portal.render() function requires a valid React element to be returned, otherwise

Currently, I am working on integrating the Semantic UI React modal into my dashboard application built using React. To facilitate this integration, I have developed a ModalManager component that will be utilized in conjunction with Redux to handle the stat ...

Strategies for managing the net::ERR_CONNECTION_REFUSED error when using Axios in a Vue.js and Django environment

I'm encountering issues with Axios while trying to send data to the backend. What steps should I take? Within the .then(response => { this.$router.push('/Log-in') return response }) section, I returned the "response" because an error mes ...

Is it possible to incorporate an expression within NG-MODEL?

Is there a way to bind an expression inside the NG-MODEL directive without causing an error? Can this be achieved using a compile function? Below is my HTML markup: <!DOCTYPE html> <html> <head> <title></title> <l ...

Accordion feature that loads JSON data dynamically with AJAX

I am facing a challenge with my HTML structure and corresponding CSS styling. The HTML code includes an accordion container with multiple sections that can be expanded or collapsed. <div class="accordion-container"> <ul class="accordion"> ...

It is not possible to make any further changes to the scene in THREE.js

Here is an example you can check out: Example Link I noticed that in newer versions of THREE.js, if the render function is called before adding additional objects to the scene, those objects will not be visible even with multiple subsequent calls to rend ...

The issue of conflicting stylesheets is causing alignment and height discrepancies when using multiple icons

Is there a way to align icons from different stylesheets to have the same height? When attempting to use icons from separate stylesheets, I encountered a height issue where one icon left space at the top and bottom while another appeared correctly aligned. ...

Troubleshooting issues with setInterval in updating HTML

Requests are being fetched through ajax: $.get("Data3.php", function (data8) { $(".data2").replaceWith(data8); }); Here's an example of the output from the database every .5 seconds: <div class="hide" id="826 ...

Aligning Bootstrap Cards in Mobile View

When viewing on mobile, the cards aren't centering properly. I've attempted to use d-flex and justify-content-center as recommended in a previous response without success. I've observed that by adding mx-auto to each card class it somewhat ...

Console Error: Attempting to set the 'className' property of null object results in an

I'm experiencing difficulties setting up the code. The function should display all songs by a specific artist when their name is entered and the button is pressed. JavaScript file: /** * Utilizes AJAX to request data about artists from an online sou ...

The issue with the page width is occurring due to a bug related to the

When pages contain the AddThis code, they tend to become very wide due to the code itself, resulting in a horizontal scroll bar appearing. However, by removing the code or changing the page direction to LTR, the issue is resolved and the page width return ...

Creating a single jQuery event that can be applied to multiple selectors simultaneously

I have created a script to animate the window to a specified element, but I had to repeat this script multiple times for each link. For example, the HTML (a standard nav menu): <nav> <a class="nav_link1"></a> <a class="nav_link2" ...

What is the best way to apply color to a Rectangle created using html5?

I am currently studying Html5. <html> <body> <canvas id="canvas1" width="300" height="200"></canvas> <script> var canvas = document.getElementById("canvas1"); var cxt = canvas.getContext("2d"); context.fillRect(0, 0, 150, ...

floating downward inside the container

Check out my website at . Everything looks great in Firefox, but when I view it in IE, the "top" button that should be floated inside the h2 titled "Unit 301: Pre-production skills" is floating to the right and getting pushed outside of the heading. Any i ...

Eliminate the ArrayOfObjects by filtering out the items with a specific ID

Here is an array of objects I've named mycart[]: [{"id":"6","quantity":"20","price":1500,"title":"casual blue strip"}, {"id":"10","quantity":"2","price":1500,"title":"casual blue round neck"},{"id":"5","quantity":20,"price":150,"title":"casual ...

Improper Placement of Bootstrap 5 Modal

I seem to be facing an unexpected issue where the Bootstrap 5 Modal and other components are displaying inside the sidebar menu instead of the main content area. Has anyone encountered this problem before? How can it be resolved? Here is a test example: ...

Shopify's feature prevents users from entering negative numbers in the quantity field

Struggling with Shopify coding, specifically the issue of negative numbers being accepted as input in my Shopify ajax setup. I've implemented a solution to reload the page if the quantity is less than 1, but ideally, I want to restrict the input to a ...

Removing an embedded document from an array in MongoDB using Mongoose when the document's status is set to false

I am in desperate need of a solution for this mongoose-related issue. My tech stack includes Express, Mongoose, and GraphQL. To give you some context, I have two collections: users and groups. user { name: string, groupAsMember: [groups], status: bo ...

Despite the presence of a producer and topic, sending Kafka messages is proving to be a challenge

Currently, I am using TypeScript and the KafkaJS library on my local machine with a single Kafka broker. After successfully connecting a producer, confirming the creation of my topic, and creating messages like so: const changeMessage = { key: id, ...

html5sql - Struggling to establish a connection with my database

I recently started using html5sql.com for my html5 DB needs and I must say, it's a fantastic module! However, I've hit a roadblock. In my index.html/index.js file, I have set up my database and created tables in it. try { html5sql.open ...

Creating a PHP JSON response that incorporates an HTML layout is a dynamic

I'm having some trouble with a certain issue: I am attempting to develop a jQuery/AJAX/PHP live search bar. Although I am successfully calling search.php, the response displayed in the console always includes the contents of my master.php file (which ...