
Added by thebman220 on October-12-2008, 9:20 pm
element.hasAttribute("tagName")
is false, because 'tagName' not an attribute. This function tests if an element object has a certain variable defined.
/**
* @param object elem : the DOM element to be tested
* @param string attr : the attribute to test for
* @return boolean : true if the attribute exists, false otherwise
*/
function elemHasAttribute(elem,attr) {
var isset;
try {
eval("isset=typeof elem."+attr+"!='undefined';");
} catch (e) {
isset=false;
}
return isset;
}
/**
* @param object elem : the DOM element to be used
* @param string attr : the attribute to get
* @return boolean : the value of the attribute or null on error
*/
function elemGetAttribute(elem,attr) {
try {
return eval("elem."+attr);
} catch (e) {
return null;
}
}
/**
* @param object elem : the DOM element to be used
* @param string attr : the attribute to set
* @param mixed val : the value to set to attr
* @return boolean : true on success or false on error
*/
function elemGetAttribute(elem,attr,val) {
try {
eval("elem."+attr+"=val;");
return true;
} catch (e) {
return false;
}
}
Added by thebman220 on May-2-2009, 4:40 am
Added by thebman220 on April-29-2009, 11:47 pm
Added by thebman220 on April-5-2009, 1:48 pm
Added by thebman220 on January-29-2009, 3:15 am
Added by thebman220 on January-29-2009, 3:04 am
