spudly.shuoink.com

the best way to predict the future is to implement it

Entries Comments


Object.hasClass()

1 December, 2007 (21:31) | JavaScript | No comments

Update: For compatibility, Object.hasClass(className) is being changed to simply hasClass(node, className).
Inspired by the dojo toolkit, this function checks to see if a given class is assigned to a node. Simply run it like this:
var my_node = document.getElementsById(”mydiv”);
if( hasClass(my_node, “myclass”) ) {
// …do something
}
Enough talk; here’s the code:
function hasClass( /*HTMLElement:*/node, /*String:*/value ) {
return [...]

alert(’Hello world!’);

29 November, 2007 (11:27) | General | No comments

So here’s my new blog - dedicated to sharing and explaining the functions that I write in javascript, php, and others …