?
Solved

JQuery and defining function parameters with $

Posted on 2012-09-19
3
Medium Priority
?
243 Views
Last Modified: 2012-12-04
Hi,

Can you help explain the difference between the two JQuery functions below.  I realize func1 uses a selector (if I passed an input control) but should it work if I just passed a string or should I use func2 for a string?

function  func1($data)
{
  alert($data);
}


function  func2(data)
{
  alert(data);
}
0
Comment
Question by:vamail2
3 Comments
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 38416418
when the parameter string you should use func2 because if
if use func1 and data is tag (a,p, i ...) results will not be as you would expect
0
 
LVL 43

Accepted Solution

by:
David S. earned 2000 total points
ID: 38420285
The only differences between those two functions is their names and the name of their one argument/parameter. The "$" doesn't mean anything special to JavaScript -- it is used for special things by convention only.

I realize func1 uses a selector (if I passed an input control)
What do you mean by "selector"? To quote the Princess Bride, "I do not think it means what you think it means".
0
 

Author Closing Comment

by:vamail2
ID: 38660548
Thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

807 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