Being a pragmatic coder I tend to miss some obvious things and I wonder, What's the difference between
$('loc')
$('#loc')
The more info the better about the ins and outs of #
In jQuery, the class and ID selectors are the same as in CSS. If you want to select elements with a certain class, use a dot ( . ) and the class name. If you want to select elements with a certain ID, use the hash symbol ( # ) and the ID name.
In jQuery, the $ sign is just an alias to jQuery() , then an alias for a function. This page reports: Basic syntax is: $(selector).action() A dollar sign to define jQuery.
These are CSS selectors. The hash symbol # means that the element is an ID. So #row would match <div id="row"> . Alternatively, the dot symbol . means the element is a CSS class.
$('loc')
is an element selector, looking for <loc>
elements.
$('#loc')
is an #id
selector, looking for id="loc"
elements.
Think CSS when looking at almost all jQuery selectors, they're very close if not identical in most cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With