I have seen the tutorial from ExtJs using the code as below:
var myDiv = Ext.get('myDiv');
myDiv.highlight();
where is hightlight() function from? Is it from native Javascript or ExtJs framework? I have done simple search but could not find it in API doc. If hightlight() is from ExtJs framework, how actually it overwrite the native behaviour in Javascript?
I wonder so how Jquery selector, let say $('#myDiv') can be recognized by Javascript? The $(”) symbol shouldn’t be recognized by Javascript compiler right?
My description is quite poor, sorry for that. I am javascript beginner.
Prototype, Ext, etc. extend the prototype of the DOM objects (which is pretty questionable behaviour by the way), e.g.
HTMLElement.prototype, and add their own functions to it. That allows you to call them like shown in your example.jQuery hovever doesn’t use any magic at all.
$is a normal identifier in JavaScript just like normal characters. So it’s nothing but a function named$which you then call when doing$('#selector')etc. The return value of that function is usually a jQuery object which behaves like an array and has a ton of useful methods. So you never deal with the native DOM objects but just with an object containing one or more of them.