0

I have this setup:

var htmlOne = "$('.class1').children('.username').html()";
var htmlTwo = "$('.class2').html()";
if(htmlTwo *= htmlOne)
{stuff};

It is supposed to see if the inner html of htmlTwo matches the inner html of htmlOne in some way. Is this set up right?

2
  • 1
    Just so it's said, comparing two HTML substrings for equality is a very rickety way of comparing elements. Consider something like isEqualNode. Commented Nov 21, 2013 at 5:32
  • I haven't used that before. How would it be used in this situation? Commented Nov 21, 2013 at 5:41

2 Answers 2

2

it should be assigned without double quotes

var htmlOne = $('.class1').children('.username').html();
var htmlTwo = $('.class2').html();

if(htmlTwo == htmlOne) {
   //stuff
};
Sign up to request clarification or add additional context in comments.

Comments

0

Can you try this,

var htmlOne = new String(htmlOne);
var htmlTwo = new String(htmlTwo);

if(htmlOne==htmlTwo){


}

1 Comment

The function within the if statement didn't do anything so I'm assuming that that doesn't work. I tried the function on its own and it does work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.