How to extend $ function in JS?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to extend $ function in JS?

  1. #1
    Join Date
    Jul 2007
    Posts
    2

    How to extend $ function in JS?

    I have a function $ that returns element by its Id, the code is something like this:
    Code:
    function $(element){
      if(typeof(element) == 'string'){
        return document.getElementById(element);
      }
    }
    I want to extend the object that this function returns with some functions like 'show', 'hide', 'opacity' etc. Prototype an jQuery are written this way.
    So I want to type this:
    Code:
    $('elementname').hide();
    for hidding the given element. It's not the problem in changinh the style of element, but in extending the $ function.

  2. #2
    Join Date
    Jul 2007
    Posts
    2
    I should probably extend the "Element" object that getElementById() returns. But how?

Similar Threads

  1. Getting a GUI to run
    By Eric in forum Java
    Replies: 4
    Last Post: 04-14-2006, 09:09 AM
  2. Packed Data(Comp-3, etc)
    By Marcos in forum VB Classic
    Replies: 3
    Last Post: 01-25-2006, 11:18 AM
  3. Getting a list of files into an array
    By Scott in forum VB Classic
    Replies: 12
    Last Post: 12-21-2001, 04:21 PM
  4. Getting a GUI to function
    By Eric in forum Java
    Replies: 1
    Last Post: 11-27-2001, 06:53 AM
  5. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center