Forum Moderators: open

Message Too Old, No Replies

setAttribute Value on List Item makes IE crash

         

trevordixon

12:33 am on Feb 7, 2007 (gmt 0)

10+ Year Member



The following makes IE 7 crash every time:

document.createElement('li').setAttribute('value', 'KillIE7');

The same works fine in Firefox. Is this an IE bug, or is there something wrong with setting the value attribute on a <li>? The getAttribute function works fine, and setAttribute works for any other attribute or for any other tag!

DrDoc

12:58 am on Feb 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is always best to create the element first, then set the attribute on that element.

elem = document.createElement('li');
elem.setAttribute('value', 'KillIE7');

Fotiman

3:05 pm on Feb 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Side Note: The "value" attribute of <li> is depreciated.