?
Solved

Javscript $

Posted on 2010-01-11
6
Medium Priority
?
238 Views
Last Modified: 2012-05-08
I have a function called

function $(elementId){

what does the symbol $ mean?  is that the name of my function?

0
Comment
Question by:gazdzid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 668 total points
ID: 26288833
0
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 668 total points
ID: 26289112
"Is that the name of my function?"

Yes.

Many of the popular javascript libraries use $ or $$ to represent a function to access any element within the DOM by either its ID or via CSS rules.

http://api.prototypejs.org/dom/dollar.html
http://api.prototypejs.org/dom/dollardollar.html
http://docs.jquery.com/API/1.3/Core 
etc.
0
 
LVL 22

Assisted Solution

by:kadaba
kadaba earned 664 total points
ID: 26290517
To put in simple terms its just another identifier/ function name
There are certain rules and naming conventions generally followed for variable names, function names etc in javascript as in any other language for that matter.

Now question would be how does this function help?
Instead of doing document.getElementById() each time to access an object this will be a short hand representation of the same. Now the advantage would be that we will be able to use this as its simple.

Generally this concept is used by powerful javascript frameworks like jquery etc. where this conept is also used to get the elements by name and class.

Remember that when you are not using such javascript frameworks you can safely use this function but when the javascript frameworks kicks in its better to avoid the usage of this function( and if you still want to use you can modify the jquery framework etc to make it work using settings in the framework). When you are not using such frameworks you can use it without any concern for easy usage.

Hope that clears your point.
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 3

Author Closing Comment

by:gazdzid
ID: 31675823
Thank you for your inputs!!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 26294303
Thanks for the points!
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 26294423
Ditto.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question