function toggle(objId) {
var el = document.getElementById(objId);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
Tuesday, 22 May 2007
toggle()
There are probably tons of toggle functions in use and i admit that this one is nothing special but it is very handy for me. The history of ‘toggling’ basically comes down to showing and hiding off elements upon an event being fired. Here is my version of it
arrayKeyExists()
This is also a function that should be a part of DOM core functionality. It checks if a key exists in an Array()
Array.prototype.arrayKeyExists = function (keyValue) {
for (key in this) {
if (key == keyValue) {
return true;
}
}
return false;
};
inArray()
This is just a simple function that extends the DOM Array object. It checks if a value is in Array()
Array.prototype.inArray = function (value) {
var c;
for (c=0;c < this.length; c++) {
if (this[c] === value) {
return true;
}
}
return false;
};
Subscribe to:
Posts (Atom)