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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:17:51+00:00 2026-05-31T03:17:51+00:00

I am having some trouble with Jquery append feature. I am wanting to have

  • 0

I am having some trouble with Jquery append feature. I am wanting to have a DIV around a PHP while loop, so I did this code and the opening div tag is called, but the closing div tag isn’t registering with its opening tag:

$('.class').append('<div class=\"class_name\">');
\\ While Loop
$('.class').append('</div>');
  • 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-05-31T03:17:52+00:00Added an answer on May 31, 2026 at 3:17 am

    jQuery only appends complete elements, you can’t append an opening div tag without jQuery automatically closing it. Try building an html string and then appending that string.

    var strOutput = "<div class='class_name'>";
    
    // replace this with php loop: for (var i = 1; i < 10; i++) {
      strOutput += i;
    // replace this with php loop: }
    strOutput += "</div>";
    $(".class").append(strOutput);
    

    UPDATE
    assuming you did a php while loop and generated a variable called $strOutput:

    $strOutput = "<div class='class_name'>some text here</div>";
    

    add it to your javascript like this:

    echo "$('.class').append('$strOutput');";
    

    another update

    Read between the lines! That was just an example… Build a single string, then echo it.

    $strOutput = "<div class='class_name'>";
    // within your while loop...
    $strOutput = $strOutput."somevalue";
    // now after your while loop...
    $strOutput = $strOutput."</div>";
    echo "$('.class').append('$strOutput');";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble with jQuery and IE. I've narrowed it down to this:
I'm having some trouble with detecting a jQuery ajax request with PHP on a
I am having some trouble with jQuery. I want to have a dialog box
I'm having some trouble getting jQuery to play nice with DokuWiki - has anyone
I'm having some trouble with the jQuery hover method. Here's the relevant JavaScript code:
I'm having some trouble with finding the visibility param for JQuery. Basically... the code
I'm very new to JQuery, and I'm having some trouble understanding how to do
I'm having some trouble with some javascript. I'm using jQuery to dynamiclly add rows
I having trouble getting append() to work in safari for some reason, but it
Im having some trouble with jQuery's slideToggle function in IE8 for some reason the

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.