Hi Karl,
The use of innerHTML is fairly common. I actually asked Klaus Hartl the
same thing awhile back and here's his reply:
"according to the IE documentation, the innerHTML property is read-only
for the following elements: col, colgroup, frameset, html, style, table,
tbody, tfoot, title and tr. And I think also select (but I'm not sure
anymore, because I cannot find anything in the docs).
Most relevant here are table and select elements I guess. Populating a
selectbox by simply changing innerHTML ( $('select').html('<option> ...
</option>') ) doesn't work. For tables a fix is already in jQuery. "
I think alot of people like using innerHTML because of the convenience
and according to this blog entry by Rob Gonda, speed:
http://www.robgonda.com/blog/index.cfm?mode=search
HTH,
Rey...
Karl Swedberg 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
> [email protected]
> http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/