Reputation:
why are some functions in JQuery case sensitive like .fadeTo or .slideDown while some are not like .mouseenter?
Upvotes: 0
Views: 95
Reputation: 707288
I think perhaps what you meant to ask is why are some jQuery methods in all lowercase, instead of mixed case.
Javascript as a language is case sensitive. A function or method name requires the correct case to function properly.
It is possible when specifying strings for code to do case insensitive comparisons and thus make any case work. There are also some attributes in HTML which are case insensitive.
In the example of jQuery's .mouseenter()
method, it is case sensitive, it's just that jQuery has defined the method name as all lower case. You will find that .mouseEnter()
does not function properly, thus it is still case sensitive.
If you want to know why jQuery defined the method as all lowercase, then we'd have to guess what their reasoning was. My guess is because the event that it is a shortcut for is all lowercase. The actual event is mouseenter
in all lowercase as in .on("mouseenter", fn)
.
So, these are equivalent:
$("#box").mouseenter(fn);
$("#box").on("mouseenter", fn);
You'd have to show a specific code example where some function was not case sensitive for us to comment on that specifically, but it can only be case insensitive if some code is specifically supporting multiple case options.
Upvotes: 2