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 7790149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:30:02+00:00 2026-06-01T21:30:02+00:00

Basically, i’m building a basic jquery modal plugin as practice, and as much as

  • 0

Basically, i’m building a basic jquery modal plugin as practice, and as much as the many varieties out in the wild have been helpful for reference, I wasn’t sure about the best method for pushing html into the modal that is being built in my jQuery.

This code is building my popups:

        var container = $('<div class="container"></div>');
        var header = $('<div class="modal"><div class="modal-header"></div></div>');
        var content = $('<div class="modal-body"></div>');
        var footer = $('<div class="modal-footer"><a class="secondary" href="#">Cancel</a><span id = "button-secondary-label">or</span><span class="green_btn"></span></div>');

        $(".popup").append(container);
        $(".container").append(header);
        $(".modal").append(content);
        $(".modal").append(footer);

In an html file that is calling the javascript file with the above code, I would like to pass html to modal-body. I know I could just write the following:

$(".modal-body").html("html goes here")

but I would like to make the plugin handle as much as possible, so what would be the best way to do the following:

in example.html:

 ...
<script type="text/javascript">
$(.popup).modal();
</script>
</head>
<body>
<div class="popup"><div class="body-text">I want this text in the .modal-body</div></div>

in the js file:

I would like to take the html that is in .body-text and move it into the .modal-body class, or something that will get me similar results.

Again, trying to accomplish this in the external js file, and not in example.html

  • 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-01T21:30:04+00:00Added an answer on June 1, 2026 at 9:30 pm

    It’s common to use IDs (as it can be set as the href and can be used to point to the given content of a link) instead when trying to target DOm element from modal boxes. So you could do

    Some content to be in the modal

    Then just grab it and append it to the cmodal

    $('#boo').appendTo(content);
    

    You can also have an option so that it can be clone and left the original copy behind

    $('#boo').clone().appendTo(content);
    

    You can technically handle classes as well but after depends how your plugin is built. As you can grab all and generate a single modal content or create the multiple content to browse between using them.

    $('.popup').each(function() {
        $(this).appendTo(content);
    });
    
    
    
    var items = $('.popup'),
    len = items.length,
    cur = 0;
    
    $next.click(function() {
        cur++;
        if (cur === len) cur = 0;
        items.eq(cur).show();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

basically I have a function that resizes elements accordingly with jquery triggering the function
Basically I have some variables that I don't want to preinitialize: originalTime = None
basically i have (state, state code) pairs, that are subsets of country [USA] ->
Basically I have an iframe loaded that is accessed from the parent whenever it
Basically, I have a JTextPane to hold some text which I wish to style.
Basically I have converted a tab delimited txt file into a list containing a
Basically, I have a main page (parent page) with a link that opens up
Basically I have an IFRAME that contains a given page - I want to
Basically I have a fixed size IFRAME with overflow: auto . The IFRAME displays
Basically I have some code to check a specific directory to see if an

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.