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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:44:26+00:00 2026-06-14T12:44:26+00:00

How do I wrap a function inside a div that doesn’t exist? So far,

  • 0

How do I wrap a function inside a div that doesn’t exist?

So far, I’ve tried .append before and after, but that closes the tag. Also tried .html, and wrap right after the function, no luck.

$("#testing .input").each(function() {
    var s = $(this).find("li .value").text();
    // start wrap
    $("span.rune > span", this).each(function() {
        var e = $(this).text();
        $("#test-output").append('<span class="' +e+ ' Rune"></span>');
    });
    // stop wrap
    $("#test-output").append('<span>' +txtToNumber[s]+ '</span>');
});

Starting HTML :

<div id="test-output"></div>

Ending HTML :

<div id="test-output">
    <div class="three">
        <span class="Z Rune"></span>
        <span class="Y Rune"></span>
        <span class="X Rune"></span>
    </div>
</div>

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-14T12:44:27+00:00Added an answer on June 14, 2026 at 12:44 pm

    You can create elements in jQuery without appending them. Then they basically “don’t exist yet”, at least not in the DOM (they are disconnected). What you can also do is creating the .three element, append it to the DOM, and then append the .Rune elements to it:

    // create .three element and append it to the DOM
    var $three = $("<div>").addClass("three").appendTo("#test-output");
    
    // map these elements to .Rune elements
    $("span.rune > span", this).map(function() {
        var e = $(this).text();
    
        return $("<span>")
                 .addClass(e)
                 .addClass("Rune")
                 .get(0);
    }).appendTo($three);  // and append them to .three
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I write a wrapper that can wrap any function and can be
jsfiddle is here: http://jsfiddle.net/M86nA/ code is this: $('div.wrap').click(function(){ var $minY = $('div.imgur-wrap').height(); if ($minY
I would like to have a function that can wrap any other function call.
I need to write a delegate function that can 'wrap' some while/try/catch code around
i'm calling the htmlspecialchars function inside another function in a class, but when i
I'm passing this inside an each loop (DOM object) to another function but in
I'm looking for a way to wrap zend_form form elements inside div's. I can
I'm trying to wrap everything inside a page's <body> tag in a div called
$('input').focus(function() { $(this).next(div.description).slideToggle(slow); $(this).wrap(' < div > < /div>').select('input'); }); <script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js></script> <blink> <input
I've started to wrap my functions inside of Objects, e.g.: var Search = {

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.