JQuery and defining function parameters with $

Posted on 2012-09-19
Last Modified: 2012-12-04

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)

function  func2(data)
Question by:vamail2
    LVL 15

    Expert Comment

    by:Minh Võ Công
    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
    LVL 42

    Accepted Solution

    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".

    Author Closing Comment

    Thank you

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    To Start with ... One of the most annoying things in developing web pages is handling the 'Enter Key' for form submission. The 'Enter Key' makes form submission so easy that the user always tend to use it. The easiest and the most intuitive way …
    PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
    The viewer will learn how to dynamically set the form action using jQuery.
    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…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now