Standards vs. Reality ... doesn't always mix very well. If someone
feels very strongly about *not* using the innerHTML property, then
that someone could use any one of the several DOM creation plugins
that are available. They all use the long route to adding elements to
the DOM (if I remember correctly).

I'm all for standards but I'm also in the trenches crunching out web
sites. The reality is that innerHTML works and it is fast. When used
by jQuery (in the respect of .append('html string')) it becomes very
readable, maintainable and I become more productive.

Let's not forget that xmlHttpRequest is also not standard.

It should be noted that when the elements are actually added to the
DOM, jQuery does *not* use innerHTML. It only uses innerHTML to
normalize some cross-browser issues and quickly get the actual
elements out of an HTML string.

--
Brandon Aaron

On 1/31/07, Karl Swedberg <[EMAIL PROTECTED]> wrote:
>
>
> Hello my jQuery friends,
>
> I received a comment on learningjquery.com this evening from someone who had
> a grievance with part of some example code. I was wondering if any of you
> would be willing to shed some light on this for me. I think what he's
> getting at is the whole "innerHTML is evil" thing, but since he doesn't
> really explain why he think it's "really ugly," I'm just not sure.
>
> Here is the relevant snippet of his comment:
>
>
>
> Nice post, but …
>  This part of code :
>
>  $('#show-alert').click(function() {
>  $('<div class="quick-alert">Alert! Watch me before it\'s too late!</div>')
> .insertAfter( $(this) );
>  }
>
>  should be AVOIDED as is. Inserting HTML code like this is really ugly, it's
> a lot better to use the DOM methods :
>
>  $('#show-alert').click(function() {
>  var oDIV = document.createElement('div');
>  oDiv.className = 'quick-alert';
>  oText = document.createTextNode("Alert ! Watch me before it's too late !");
>  $(oDiv).append(oText);
>  $(oDiv).insertAfter(this);
>  }
> I'd love to hear your opinions about this. With HTML/CSS stuff, I'm obsessed
> with standards and such. And one of the things that has always really
> attracted me to jQuery is its unobtrusiveness. I also read Jeremy Keith's
> DOM Scripting book and really appreciated his approach -- which is similar
> to what this commenter is suggesting. But I also love the super-fast
> development that can be done with jQuery and don't want to have to give that
> up if it's just a matter of someone's aesthetic sensibility being offended.
> I guess I just want to do the right thing.
>
> thanks,
>
> --Karl
> _________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
>
>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to