How to compare two HTML elements

前端 未结 4 1468
梦毁少年i
梦毁少年i 2020-12-01 06:19

How can we compare two HTML elements whether they are identical or not ?

I tried this thing but no luck

Hi this is sachin ten
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 07:14

    Why not do it the easy way?

    Hi this is sachin tendulkar
    Hi this is sachin tendulkar
    if($('#div1').html() == $('#div2').html()) alert('div1 & div2 are the same'); else alert('div1 & div2 are different');

    http://jsfiddle.net/5Zwy8/1/

提交回复
热议问题