Reputation:
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:
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
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
Reputation: 2452
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.
"$" in $xml changes nothing, $xml
is a valid variable name just like other variable names.
Upvotes: 1