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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:36:02+00:00 2026-05-21T02:36:02+00:00

I have a DIV with a form in it. When users submit the form

  • 0

I have a DIV with a form in it. When users submit the form and it gets successfully submitted, I replace the form with a simple “everything is good now” message:

$("#some_div").html("Yeah all good mate!");

Is there a good way to “reset” the div to its “original state” as per the HTML it has arrived with? I can only think of actually doing something like this:

//before I change the DIV
var originalState = $("#some_div").html();
//manipulate the DIV
//...
//push the state back
$("#some_div").html(originalState);

It doesn’t look very elegant – I guess there is a better solution for this, no?

  • 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-21T02:36:03+00:00Added an answer on May 21, 2026 at 2:36 am

    I would clone the element, instead of saving the content. Then use replaceWith to restore it:

    var divClone = $("#some_div").clone(); // Do this on $(document).ready(function() { ... })
    
    $("#some_div").html("Yeah all good mate!"); // Change the content temporarily
    
    // Use this command if you want to keep divClone as a copy of "#some_div"
    $("#some_div").replaceWith(divClone.clone()); // Restore element with a copy of divClone
    
    // Any changes to "#some_div" after this point will affect the value of divClone
    $("#some_div").replaceWith(divClone); // Restore element with divClone itself
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form (signup.php) that pops up in a nyroModal window when I
Hi I have multiple elements with the same structure in my application. Second div
I've got a form where users can edit members of a group. So they
I have created a new migration: class AddSignatureToUser < ActiveRecord::Migration def self.up add_column :users,
id like to have an input box that a user can enter a search
I have a page that is using jQuery tabs. Within one of my tabs
I have a favourite and un-favourite functionality in my application and I am using
I am working on a comment system on a social network, I am using
I'm using a slider as user input for a screen. Basically it's a bulk
I've inherited some code that I need to debug. It isn't working at present.

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.