Possible Duplicate:
When should I use double or single quotes in JavaScript?
Do ""
and ''
have different meanings in JavaScript?
Because I keep seeing those two usages in jQuery, for instance:
$("")
and
$('')
Possible Duplicate:
When should I use double or single quotes in JavaScript?
Do ""
and ''
have different meanings in JavaScript?
Because I keep seeing those two usages in jQuery, for instance:
$("")
and
$('')
Read about strings in JavaScript. There is no difference.
But as HTML properties are often defined with double-quotes, I would use single-quotes, which makes code like
$('<a href="someurl" />')
easier to write.
Use the one with which you have less characters to escape inside the string.
No, they mean the same thing; they are both just JavaScript string literals.
Having have multiple different quote styles is useful so that:
"some string with 'single quotes' in it"
, or 'a string with "double quotes" in it'
, and<button onclick="alert('foo')">Click me</div>
They both are string delimiters. The only difference is if you can use " to enclose a string with ' in it, and you can use ' to enclose a string with " in it.
You can use either. I recommend sticking to one standard though throughout your project, things can sometimes get a little messy when interchanging between them when combining with server side code.
No... since isn't possible use "" inside "", the "" and '' make a good combination when need quote a string inside another.