spudly.shuoink.com

the best way to predict the future is to implement it

Entries Comments


more class functions…

6 December, 2007 (19:35) | JavaScript | 4 comments

Update: changed from Object.prototype.hasClass(className) to simply hasClass(element, className) for cross-browser compatibility
Ok… nothing to revolutionary here. This has been done before lots of times. I’ve written two new functions to go along with my hasClass() javascript function.
First is addClass(), which simply adds a class to an object, while preserving the existing classes. Here it is:
function addClass( [...]

the ultimate getElementsBy*: Object.getElementsWhere()

1 December, 2007 (21:14) | JavaScript | 3 comments

Update: for compatibility, Object.getElementsWhere(”condition”) is being changed to getElementsWhere(node, condition) where node is the node to search in.
I’ve looked a lot lately at the getElementsByClass() function and other getElementsBy functions, but they all seemed rather inadequate to me.
I rewrote the function about three times before I figured out what to do. What I really wanted [...]