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,030
  • 21
  • 100
  • 124
Don Lee
  • 457
  • 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.

Chris Jester-Young
  • 213,251
  • 44
  • 377
  • 423
2

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

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Darian
  • 348
  • 1
  • 8
2

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

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Mr Ob
  • 36
  • 2