Posted By

noah on 05/24/07


Tagged

object element DOM String functions parameters interface flexible viarobzand


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Accept a parameter that is /either/ a DOM element /or/ the ID of a DOM element.


 / Published in: JavaScript
 

  1. function foo (idOrEl) {
  2. var el = (typeof idOrEl == 'string' ? document.getElementById(idOrEl) : idOrEl);
  3. }

Report this snippet  

You need to login to post a comment.