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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:31:12+00:00 2026-06-15T21:31:12+00:00

I have a little issue with jquery . Let say i have the following

  • 0

I have a little issue with jquery .

Let say i have the following statement :

var content = $('#details').html();

How do i find something inside content ?

This is what i’ve tried :

// i want to empty the data inside the id=student
content.find('#student').html('');

But since content is a string … how can i assign HTML to a variable and be able to search that ?

Update :

Here is what i’m trying to achieve :

I have an ajax query and i need the (#details) structure intact .

If i empty the structure and then for a different ajax query i might need to do some replacement inside #student which wont be available because it was cleared …

ex:

<div id="details">

 <div id="student">
   <span> {%weeks%} </span>
 </div>

 <div id="teacher">
   <span> {%whatever%} </span>
 </div>
</div>

so sometime i need to clear student / sometime teacher depending on the ajax query , that’s why i make a copy of the 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-15T21:31:13+00:00Added an answer on June 15, 2026 at 9:31 pm

    As IDs must be unique you can select the element directly by ID which is more efficient that creating a redundant jQuery object.

    $('#student').html('');
    

    You can also use empty method:

    $('#student').empty();
    

    Note that if you are using ajax, you can use html method for changing the html content of the element and there is no need to removing html contents.

    // ...
    success: function(data) {
         $('#student').html(data);
    } 
    

    In case that you want to cache the object, you can use end method for returning to previous state:

    var $content = $('#details');
    $content
       .find('#something').foo().end()
       .find('#anotherElement').bar().end()
    

    Or if you want to copy the element, use clone method:

    var $contentCloned = $('#details').clone();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a little issue with placing divs inside a jQuery UI
so I have a little issue with my jQuery Captify (Caption on image rollovers)
I have this little jQuery plugin: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
I have a little issue with a application wich is specified the following: I
OK, I'm just getting to grips with jQuery and have a little issue. I
I have a teeny tiny little issue concerning a jQuery-based slideshow in Opera. What
just having a little issue figuring this jquery problem out. I have a table
I have a little issue with my hibernate logging configuration. In our application, we
I have a little issue with my CSS: I have a hyperlink element which
I have a little issue concerning an animation-effect which loads a certain div into

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.