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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:14:01+00:00 2026-06-03T14:14:01+00:00

Currently I am trying to compare two variables, newhtml and oldhtml . I get

  • 0

Currently I am trying to compare two variables, newhtml and oldhtml.
I get the old html using:

var oldhtml = $('#pop').html();

I get the new html using:

var newhtml = ("<%= escape_javascript render(:file => 'shared/_content') %>");

I’m then trying to compare them using:

if(newhtml == oldhtml)
{
  //is never called
  $('#pop').hide();
}
else
{
  //is always called
  $('#pop').html(newhtml);
}

but it’s not working. In this scenario the oldhtml variable is actually just the previous newhtml variable. So, if you click on the same content on the main page newhtml should actually just be a ruby on rails generated version of oldhtml (the html present in <div id="pop">). I’ve tried appending them to see where there difference lies, but it looks exactly the same to me. I was hoping someone could nudge me in the right direction? 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-03T14:14:05+00:00Added an answer on June 3, 2026 at 2:14 pm

    That was all very helpful and I actually sort of combined the answers to get something that worked. What ended up working is this:

    Get the oldhtml like before:

    var oldhtml = $('#pop').html();
    

    Then insert the new html into the div:

    $('#pop').html("<%= escape_javascript render(:file => 'shared/_content') %>");
    

    Following that, get the newhtml from the div, the same way I retrieved the oldhtml:

    var newhtml = $('#pop').html();
    

    The if statement then works, but you want to make sure to change the div to something arbitrary that can’t be retrieved from your database:

    if(newhtml == oldhtml)
    {
    $('#pop').html("<h>toggled_off</h>");
    $('#pop').hide();
    }
    else
    {
    $('#pop').html(newhtml);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to use the XMLUnit library to compare two XML files.
Hey guys, I'm currently trying to implement a function using C that takes in
I'm trying to write a Compare method to compare properties in some POCOs using
I currently have a dataset which has two columns that I'd like to compare.
I'm trying to compare four arrays. Two of the four arrays store filenames, while
I am trying to create a new custom validation in which I can compare
simply trying to compare two user defined vectors to see if they are equal,
I am trying to compare two dates which are in Finnish time form like
In this code I am trying to compare two strings with jQuery. The current
I'm trying to compare two dates in PHP and figure out how many days

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.