简体   繁体   中英

Comparing innerHTML with jQuery

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?

it should be assigned without double quotes

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

if(htmlTwo == htmlOne) {
   //stuff
};

Can you try this,

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

if(htmlOne==htmlTwo){


}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM