user8263191
user8263191

Reputation:

what does JQuery's "$" symbol mean?

so plz forgive me for my silly question, I know "$" is a shortcut for jQuery, but I've been seen some code like:

  var xml = "<rss version='2.0'><channel><title>RSS Title</title></channel></rss>",
  xmlDoc = $.parseXML( xml ),
  $xml = $( xmlDoc ),
  $title = $xml.find( "title" );

so my questions are:

  1. How come there is no "var" prefix for xmlDoc? shouldn't it be:

    var xmlDoc = $.parseXML( xml )?

2.what does the "$" in $xml stands for? if xml is a variable, shouldn't it be:

var xml = $( xmlDoc )?

Upvotes: 0

Views: 73

Answers (2)

Richard Mneyan
Richard Mneyan

Reputation: 692

There might be other libraries also using jQuery shortcut $. This link might help better understand shortcut for jQuery:

http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/

Upvotes: 0

vatz88
vatz88

Reputation: 2452

  1. no "var" prefix for xmlDoc is valid, it is using short syntax of variable declaration (see ,). Even if there were no , it'll declare a global javascript variable.

  2. "$" in $xml changes nothing, $xml is a valid variable name just like other variable names.

Upvotes: 1

Related Questions