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

  • Home
  • SEARCH
  • 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 8811049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:16:01+00:00 2026-06-14T03:16:01+00:00

I am using SimpleModal to trigger multiple modals on a page. The jQuery looks

  • 0

I am using SimpleModal to trigger multiple modals on a page. The jQuery looks like this:

jQuery(function ($) {
    $('#basic-modal .basic').click(function (e) {
        $('#basic-modal-content').modal();

        return false;
    }); 
});

However, I have multiple modals on a page, each with a different ID… such as:

#basic-modal_2
#basic-modal-content_2 
#basic-modal_3
#basic-modal-content_3

Etc…

I can achieve this by just adding more jQuery such as:

jQuery(function ($) {
    $('#basic-modal .basic').click(function (e) {
        $('#basic-modal-content').modal();

        return false;
    }); 

   $('#basic-modal2 .basic').click(function (e) {
        $('#basic-modal-content2').modal();

        return false;
    }); 
});

But this is wildly inefficient. Is there a way I can just look for the the end of the ID with one call rather than repeating the same thing with different IDs?

Thanks!

  • 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-14T03:16:02+00:00Added an answer on June 14, 2026 at 3:16 am

    You can store the id of the modal in the data-modal-id attribute of .basic

    <div id="basic-modal" >
       <div class="basic" data-modal-id="basic-modal-content">
    
       </div>
    </div>
    
    jQuery(function($) {
        $('.basic').click(function(e) {
    
            var id = $(this).data('modal-id');
            $('#' + id).modal();
    
            return false;
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing Simplemodal in an application of mine using this code: $(.dialog-link).live('click', function(e) {
i am using jquery.simplemodal-1.1.1 and jquery-1.2.6.min to create a modal popup. this is my
I'm using http://dev.mariusilie.net/content/simple-tooltip-jquery-plugin for my tooltip and simple modal for a modal window. I've
I use this call to create modal window using simplemodal ( http://www.ericmmartin.com/projects/simplemodal/ ): $.get(openform/,
I'm using simple-modal http://www.ericmmartin.com/projects/simplemodal/ I have one modal that opens on a button click,
I'm having an issue where when initializing a modal window using the jquery.simplemodal plugin.
I am using Eric Martin's SimpleModal plugin 1.4.1 with JQuery 1.4.2 to display basic
I'm using Eric Martin's SimpleModal plugin for a page that has several different modals.
I'm using this simple modal dialog example here: http://jqueryui.com/demos/dialog/modal-form.html When the page loads, jQuery
Greetings! I'm using this excellent jQuery plugin and would like to know how to

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.