Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between $ and $$?

I have been going through some jQuery functionality.

Can any one please give me some idea of what the difference is between the use of $ and $$?

like image 610
Amar Avatar asked Dec 18 '12 12:12

Amar


People also ask

What is the difference between $@ and $*?

$* Stores all the arguments that were entered on the command line ($1 $2 ...). "$@" Stores all the arguments that were entered on the command line, individually quoted ("$1" "$2" ...).

What is the difference between single and double quotation marks?

General Usage Rules In America, Canada, Australia and New Zealand, the general rule is that double quotes are used to denote direct speech. Single quotes are used to enclose a quote within a quote, a quote within a headline, or a title within a quote.

Whats the difference between {} and [] in JavaScript?

The difference between “{}” and “[]” is that {} is an empty array while [] is a JavaScript array, but there are more! In JavaScript, almost “everything” is an object. All JavaScript values, except primitives, are objects. Therefore if you understand objects, you understand JavaScript.

What's the difference between quotation marks and apostrophes?

But I bet you're curious about how they're different, why else would you be here? The main difference between the two is: Quotation marks are used to report speech. An apostrophe is used for making contractions and possession.


1 Answers

$ and $$ will work on any web page (if jQuery is not included also) on Google Chrome, Firefox and Safari browsers where $ returns first element of selector passed.

Here,

$ is document.querySelector

$$ is document.querySelectorAll

They are native functions of Google Chrome and Firefox browsers, you can see $ and $$ definition in Safari as well.

Open Google in any of Google Chrome, Firefox or Safari, and open Developer Tools to check these results... (why Google, because they won't use jQuery or Moo tools)

$('div');  // returns first DIV in DOM
$$('div'); // returns all DIVs in DOM

enter image description here

like image 162
Ranganadh Paramkusam Avatar answered Nov 09 '22 23:11

Ranganadh Paramkusam