Proceed to the section with modal

My goal is to create a modal with 4 sections, each loading its content dynamically using the .load() function to the container on the right side.

The challenge I'm facing is that I have a footer menu that triggers the modal to open, and I need it to direct the user to the specific section they clicked on.

For example, if a user clicks on the 'payment methods' option in the footer menu, the modal should open directly in that particular section. Any suggestions on how to achieve this?

This is the script I use to open the modal:

function loadmodal(){
     $('.info_modal').fadeIn();
}

And here's the script for loading the content of the sections within the modal after clicking on the left menu:

function loadcontent(){
     $('.info_modal_content').load('includes/text2.html');
}

Here is the markup structure of the modal:

<div class="info_modal">
    <div class="info_modal_container">
        <h2>Shopping Guide</h2>
        <hr>
        <ul class="info_modal_menu">
            <li>
                 <a href="javascript:void(0)">How to Buy</a>
            </li>
            <li>
                 <a href="javascript:void(0)" onclick="loadcontent()">Payment Methods</a>
            </li>
            <li>
                 <a href="javascript:void(0)">Exchanges and Returns</a>
            </li>
            <li>
                 <a href="javascript:void(0)">Gift Card</a>
            </li>
         </ul>
         <div class="info_modal_content">
             <h2>WHERE TO BUY YOUR GIFT CARD...</h2>
             <p>Your card may be rejected by one of the retailers.</p>
         </div>

         <a href="javascript:void(0)" class="close_contact" onclick="closecontactmodal()"></a>
     </div>
 </div>

Answer №1

Is it possible to pass a URL for the initial load instead?

If your footer has a structure similar to this:

<footer>
  <ul>
    <li><a href="text1.html" class="openModal">Text 1</a></li>
    <li><a href="text2.html" class="openModal">Text 2</a></li>
    <li><a href="text3.html" class="openModal">Text 3</a></li>
    <li><a href="text4.html" class="openModal">Text 4</a></li>
  </ul>
</footer>

You can then add an event handler to .openModal:

$('.openModal').on('click', function(e){
  e.preventDefault();

  var toLoad = $(this).attr('href');

  $('.info_modal_content').load(toLoad);

  $('.info_modal').fadeIn();
});

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

React, Redux, Thunk - the trifecta of powerful

After spending a considerable amount of time struggling with this particular piece of code, I have scoured online resources such as Stack Overflow and the documentation, but there is still something that eludes me... The code in question revolves around t ...

When attempting to import a component from react-bootstrap, an error is thrown

Every time I try to use a component from 'react-bootstrap', I encounter a strange error. Here is a small example where I am importing the "HelpBlock" component. import PropTypes from 'prop-types'; import React from 'react'; i ...

I am experiencing difficulties with my bootstrap module not loading

Could you please investigate why my module isn't loading? The module is supposed to load under the specified conditions in the third last column, but when I test the code, it doesn't work. Can you assist me in identifying what might be causing th ...

Is there a way to incorporate the Indian rupee symbol into a Google chart?

I've been trying to incorporate the Indian Rupee symbol into a Google chart using the code below: var formatter = new google.visualization.NumberFormat({ prefix: '&#8377;' }); However, I'm encountering an issue where ...

Toggling the status of a Blank Checkbox

Working with a set of checkboxes, one is labeled conditions[]. The final checkbox in this group is titled "none". When this checkbox is selected, it should automatically check all the other checkboxes in the array. I am currently trying to determine the b ...

Toggle classes on button click

<div class='fixed_button homes hidden'> <a class='btn btn-primary homes'>Continue &rarr;</a> </div> Using jQuery Library $(".homes").on('click', function(){ $("choose_style").addClass(&apo ...

Expressing the assignment of arrays inside the req.body object to separate variables

I've been facing some challenges trying to get Express and body-parser to properly interpret the JSON object sent from the Angular side of my app. It seems like there might be an issue with how I'm assigning variables in my syntax. Despite trying ...

Searching and paginating through custom post types using an ajax call with $wpdb

I have recently developed a customized post type called "news" using Wordpress, and I am looking for a way to search through these posts and implement pagination without causing page reloads. Currently, I am utilizing the $wpdb class which is functioning ...

Is it possible to conceal an HTML form once it has been submitted

I have a form on my website that sends the entered information to a PHP script which then emails me the details. I've implemented JavaScript form validation and jQuery Ajax to ensure the page doesn't need to be reloaded. Here is the HTML code fo ...

Issue with typings in TypeScript is not being resolved

I have integrated this library into my code Library Link I have added typings for it in my project as follows Typings Link I have included it in my .ts file like this import accounting from "accounting"; I can locate the typings under /node_modules ...

Is it possible to use Highcharts in AngularJs without jQuery?

Is there a way to use Highcharts without relying on the full jQuery library? The current popular option seems to require jQuery, but I'm having trouble getting it to work without it: https://github.com/pablojim/highcharts-ng Can I develop a Highchart ...

Using PHP and JQuery to Implement Cloudinary Callbacks

After uploading images to my cloudinary account, I am unsure where cloudinary is directing the image_id. The documentation mentions that cloudinary_cors.html is supposed to be the destination for Cloudinary's callbacks, but this seems odd as it doesn& ...

CSS image buttons are causing active_link_to list items to disappear when they become inactive

I'm struggling to get the nth css button/list elements to display correctly using active_link_to. The first css button appears without any problems and is active, but when I try to add new buttons to the list, they seem to disappear. HTML <li cla ...

Switching images using jQuery

Issue I'm feeling overwhelmed by the abundance of JavaScript code hints and finding it difficult to determine where to begin. Any assistance would be greatly appreciated. Essentially, I have a primary full-screen background image set in the CSS on t ...

Is there a way to utilize nodemon without having to install it through npm?

I'm having trouble with my network not allowing me to use npm install. Is there another way for me to install and use nodemon? I've noticed that Node only runs after setting PATH variables on Windows. I attempted to set the path for nodemon, but ...

Issues encountered when attempting to update only a portion of a webpage through AJAX with

I'm relatively new to the world of web development, and I'm currently tackling a straightforward project within Rails. At this moment in time, there's a database housing various entries, each marked with an entry date. On the index page, eve ...

What is the best method for integrating UL / LI into JSON to HTML conversion?

Currently, I am working on converting a JSON string into HTML format. If you want to take a look at the code, here is the jsfiddle link: http://jsfiddle.net/2VwKb/4/ The specific modifications I need to make involve adding a li element around the model da ...

CoffeeScript equivalent of when the document is loaded

Recently, I've been delving into Coffeescript for my web application, but I'm encountering a frustrating issue. The methods are not being called until I manually reload the page. I suspect that the missing piece may be the $(document).ready(func ...

Including new styles in CKEDITOR.stylesSet that pertain to multiple elements

My idea involves creating a unique bullet list style with two specific features: a. A blue arrow image replacing the standard list icon b. Very subtle dotted borders above and below each list item. I am looking to incorporate this design into CKEditor t ...

The Full Screen Button on Google Maps isn't functioning properly in a third-party mapping application

Below you will see the '+' icon which is also supposed to function as the full screen button. https://i.stack.imgur.com/IMvHa.png However, when clicked on, it does not expand to full screen as intended. I have attempted using some basic jQuery ...