I have an issue where $("#register") returns null
, but jQuery("#register")
returns object correctly.
This may be worth thousand words:
As you can see in Watch expression everything works as expected (jQuery === $ returns true
)
But in console it doesn't. And in code it also doesn't, because the $("#register").validate
string doesn't work.
Maybe it has to do something with $script.js thing?
jQuery is a JavaScript library, so it operates on top of JavaScript. It cannot exist on its own, so you can't use one over the other. You can use just JavaScript or JavaScript and jQuery. jQuery was introduced to make development with JavaScript easier.
The $() function The dollar function, $(), can be used as shorthand for the getElementById function. To refer to an element in the Document Object Model (DOM) of an HTML page, the usual function identifying an element is: document.
The value of this inside a click event is a DOM element (the one that was clicked). Using $(this) converts it to a jQuery object. DOM elements do not have a hide() methods, but jQuery adds that and many other methods you can then call.
Maybe some other javascript framework that you are using hijacks the $()
function. You may take a look at jQuery.noConflict()
for tips about using jQuery with other frameworks.
I'm sorry to return in 5 minutes and say that the code works. Uh.
It's just that $ is something the web inspector overrides.
The $script.js doesn't cause conflicts.
> jQuery.noConflict()
function (a,b){return new d.fn.init(a,b,g)}
> $
function ()
{
return document.getElementById.apply(document, arguments)
}
It's the chrome inspector problem :)
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