title: Jquery: replace content only if the new content is different
body: <p>I have a php file which is called every X second in ajax to refresh a content. This php file return a js file wich must change the html content of a div with a effect.</p>
  
  <p>But I would want to change this content only if the new is different! Else, I have a div which refresh itself with the effect even if it's the sames contents!</p>
  
  <p>I tested with this code:</p>
  
  <pre><code>if ($('#mydiv').html()!=data_insertion) $('#mydiv').fadeTo("fast", 0, function () {$(this).html(data_insertion).fadeTo("fast", 1)});
  </code></pre>
  
  <p>But this code isn't cross browser... Indeed, my data_insertion variable contains some html content. And each browser insert it changing the attribut order etc. That's why, $('#mydiv').html() is never equal to data_insertion.</p>