1

What is the difference between $('.abc') and $(".abc") in jQuery?

Example:

var main = function() {
 $('.btn').click(function(event) {
   $('.container').hide();
 });
};

vs

var main = function() {
 $(".btn").click(function(event) {
   $(".container").hide();
 });
};

Both of the code snippets work well. So what is different?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Don Lee
  • 465
  • 2
  • 11
  • Single and double quotes have nothing to do with jQuery, it's an element of JavaScript. But there is no difference in JS. – Kulvar Jun 14 '16 at 08:07

3 Answers3

4

They are exactly the same. JavaScript strings can be delimited by either single or double quotes.

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
2

No difference; they both are missing a class or ID selector.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Darian
  • 348
  • 1
  • 8
2

In jQuery, there isn't any difference between single or double quotes.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mr Ob
  • 36
  • 2