What is '$(elementname)'

G

glenhong

Can anyone explain to me what the $(.......) means??

ClassName.prototype = {
initialize : function(element1, element2) {
this.element = $(element1);
this.container = $(element2);
}

Thanks in advance
 
R

Richard Cornford

Can anyone explain to me what the $(.......) means??

ClassName.prototype = {
initialize : function(element1, element2) {
this.element = $(element1);
this.container = $(element2);
}

It is a call to an obscurely (and poorly) named function. The function
must be defined somewhere in code or calls to it will error out, and
that functi9on definition will determine what the function actually
does. There is a convention in ECMA 262 (the specification for the
standardised code or javascript) that Identifiers beginning with the -
$ - are intended to indicate that they are machine generated, but
authors who arre not familiar with the language often act in ignorance
of that.

Richard.
 
R

Richard Levasseur

Can anyone explain to me what the $(.......) means??

ClassName.prototype = {
initialize : function(element1, element2) {
this.element = $(element1);
this.container = $(element2);
}

Thanks in advance

It could be the shorthand re-implementation of getElementById(). Thats
the only time i've ever seen a function named $.
 
T

Trond Michelsen

Can anyone explain to me what the $(.......) means??
ClassName.prototype = {
initialize : function(element1, element2) {
this.element = $(element1);
this.container = $(element2);
}

As Richard C. and Richard L. has already said, it's a function, and it
seems like it in this case is a shorthand for document.getElementById().
There is a library called prototype.js that defines a function $() which
behaves like this, so my guess is that your code requires prototype.js
or some other library built on, or inspired by, it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top