4 ms·
Unfortunately it's not as simple as it is with events. With events you have the advantage of binding to a single point (e.g. the document node) and using the na
by jeresig 18y ago
Unfortunately it's not as simple as it is with events. With events you have the advantage of binding to a single point (e.g. the document node) and using the native event bubbling that exists in all browsers to capture any event that occurs on the page. This way we can detect a click on a new DOM element that we haven't seen before.
We don't have that luxury with CSS. There's no universal way for all browsers to let JavaScript know when a new element has been added to the page - or that it's been moved. There's the W3C DOM mutation events but they aren't implemented everywhere.
More info: http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mutationevents http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-e...
- Raphael 18y agoWhat? I thought you could just edit the stylesheet object. Thanks for your quick response.
- jeresig 18y agoWell, we could certainly inject new stylesheet rules but that's bound to cause problems since we're at the mercy of the browser CSS engines. I suspect that most jQuery users enjoy writing selectors like "div:first > span" which will be completely null-and-void once we step out of our protected JavaScript garden. Since we can't get full API compatibility it really makes the prospect not very exciting for us.