Single or Double quotes in jQuery

JavascriptJquery

Javascript Problem Overview


> Possible Duplicate:
> When to Use Double or Single Quotes in JavaScript

This is specifically for jQuery not JavaScript in general since I'm not a JavaScript programmer and I'm starting to learn jQuery.

With the release of jQuery 1.6 was there a specific change on using single or double quotes?

For example, would the following function work in jQuery 1.6?:

$('.selector').show();

Or do I have to use double quotes?:

$(".selector").show();

Thanks in advance for any clarification.

Javascript Solutions


Solution 1 - Javascript

JQuery Core Style Guidelines says:

"Strings should always use double-quotes instead of single-quotes."

Solution 2 - Javascript

You are allowed to use both. In JavaScript there is no difference between both (while e.g. in PHP there is a difference).

By the way, this is a JavaScript question. You are passing a string to the $() function, and strings have to be surrounded by ' or ".

Solution 3 - Javascript

jQuery is JavaScript and as such emits the same behavior: Both behave the same, because both represent a string.

Is there any specific reason you think that jQuery 1.6 changed something here?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRicardo ZeaView Question on Stackoverflow
Solution 1 - JavascriptFrinkView Answer on Stackoverflow
Solution 2 - Javascriptjs-coderView Answer on Stackoverflow
Solution 3 - JavascriptMichael StumView Answer on Stackoverflow