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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:19:10+00:00 2026-06-07T17:19:10+00:00

I have a div as follows: <div><p></p></div> Thus when I do, var div_contents =

  • 0

I have a div as follows:

<div><p></p></div>

Thus when I do,

var div_contents = $("div").html()

then

div_contents = "<p></p>"

However I have another function that is dynamically changing the content of the div, let’s say, to <div><h2></h2></div>

Thus, my div_contents value is changing from "<p></p>" to "<h2></h2>"

How can I keep the value of div_contents from changing so that I can use it as a final or static variable or something?

  • 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-07T17:19:12+00:00Added an answer on June 7, 2026 at 5:19 pm

    div_contents will only change when you make an assignment. If the value of div_contents is <h2></h2>, is is because that was the state of the div when you called $("div").html(). If the div changes after that, the variable will retain its value until you make another assignment.

    I would need to see more of your code to see what is really going on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML code as follows; <div>Content table with varying height</div> <div id=buttons>
I have a layout as follows: <div style=width: 300> <div style=width: 300>Some Content</div> </div
If I have a drop down list as follows <div class=editor-label> <%= Html.DropDownListFor(model =>
I have coded a simple div containing an image that follows the mouse cursor
I have a div in an html file defined as follows: <div id=rangeTabAll></div> In
I have the code as follows: <html> <head> <style type=text/css> #container { } #content
I have a div that has scrollable content, but it is vital that this
I have a div on a page that I need to put content into.
I have this javascript file ( $(#paper2) is a div) var lines=0; $(document).ready(function() {
I have an div element in website markup as follows. <div id=mainContainer class=container runat=server>

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.