Reputation: 43
For example, the CSS methods seem to be camelCase: http://api.jquery.com/category/css/,
But the mouse events are all lowercase: http://api.jquery.com/category/events/mouse-events/
Is there logic to this?
Upvotes: 2
Views: 842
Reputation: 700302
The convention in JavaScript is to use camel case for identifiers. jQuery uses camel case for all method names, except for methods where the name is the same as event names.
In HTML the event names are not case sensetive, so variants like onmouseover
, OnMouseOver
and ONMOUSEOVER
have been used. In XHTML the attribute names have to be lower case, and that is often used for HTML now as well, so that the code works for both HTML and XHTML.
In jQuery methods like mouseover
and keypress
are not camel case, they are lower case just like the onmouseover
and onkeypress
attributes as used in XHTML.
Upvotes: 2
Reputation: 26434
In JavaScript, all events use lowercase identifiers (onclick
, etc.). This is probably because it's an artifact of inline events in HTML.
CSS methods are in camelCase
because that is the JavaScript convention. Event methods are in lowercase, probably because that's the HTML convention.
Take a look at this page for more details.
http://www.w3schools.com/tags/ref_eventattributes.asp
Upvotes: 3