2009
12.08

I just stumbled an error in IE using html() method for altering html content of elements and I even using the latest version/stable of jquery. And some part of the scripts are really working using html(), some are not.  So I did a quick fix to overload html() method to work for IE.

Code :

Alternative 1

if($.browser.msie)

{

(function($){

$.fn.html = function(contents)

{

this.innerHTML = contents;  return $(this);

}

})(jQuery);

}

Alternative 2

$(‘#divId’).each(function(){this.innerHTML=”yourcontent here….”‘;});

Explanation : I traced the error inside the jquery and its pointing on appendChild, parentNode and firstChild. But I don’t want to alter the jQuery script so i just use innerHTML to put html content inside an element.

{
$(“.divsep”).css({‘margin-top’:

What if html() method won’t work on IE?

1 comment so far

Add Your Comment
  1. [...] This post was Twitted by codezyne [...]