On Tue, Dec 9, 2008 at 10:27 AM, Brett Patterson
<[EMAIL PROTECTED]> wrote:
> To All,
>
> I was playing around with a page where I found out that just about
> everything that I wanted to do I had to use:
>
> function namedFunction(layer)
>  {
>  var whatever = document.getElementById(layer);
>  // other code here.
>  }
>
> And I got really annoyed at having to either copy and paste or retype the
> getElementById(layer) part. So I thought about a way to not have to retype
> it (and make it cross-browser compatible) and to assign it a variable that I
> could use over and over again.

Just about ever Javascript framework does something similar to:

function $(id) {
  return document.getElementById(id);
}

So then you can just do:

$('header');

But if you really want cross-browser compatibility and also
ease-of-use, I would suggest combining unobtrusive practices with a
decent JS framework. There's a lot of gotchas out there.


-- 
--
Christian Montoya
christianmontoya.net


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to