W3C home > Mailing lists > Public > www-html@w3.org > October 2012

Re: Syntax to access div by ID.

From: Patrick H. Lauke <redux@splintered.co.uk>
Date: Fri, 12 Oct 2012 14:23:55 +0100
Message-ID: <507819EB.6010906@splintered.co.uk>
To: www-html@w3.org
On 12/10/2012 14:21, Patrick H. Lauke wrote:
> On 11/10/2012 13:05, Gautam Sathe wrote:
> [...]
>> <div id="testDiv">...</div>
>>
>> In a script section he was trying to set its display property to 'none'
>> and he had coded it like:
>>
>> testDiv.style.display = 'none';
> [...]
>
> I seem to remember this was something IE did first, and other browsers
> have adopted the behavior for compatibility reasons. It may actually now
> be standardised somewhere in HTML5/Living Standard.

And I'm told it may have issues in browsers like older versions of 
Firefox when the page is not in quirks mode...so worth testing.

Personally, I'd still use getElementById purely for clarity. It's not 
like those few bytes will make a whole lot of impact on code size, IMHO.

P
-- 
Patrick H. Lauke
______________________________________________________________
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]

www.splintered.co.uk | www.photographia.co.uk
http://redux.deviantart.com | http://flickr.com/photos/redux/
______________________________________________________________
twitter: @patrick_h_lauke | skype: patrick_h_lauke
______________________________________________________________
Received on Friday, 12 October 2012 13:24:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 12 October 2012 13:24:37 GMT