Use at own risk. Programs haven't been thoroughly tested.
function: setTagStyleByAttr
Sets a style to all tags whose attribute corresponds with a value
Info
@author Kevin van Zonneveld
@version 0.1
@link http://kevin.vanzonneveld.net
@param (string) strobj The type of tag
@param (string) stratt The name of the attribute
@param (string) strval The value to match
@version 0.1
@link http://kevin.vanzonneveld.net
@param (string) strobj The type of tag
@param (string) stratt The name of the attribute
@param (string) strval The value to match
Example
Usage
Outputs
(sets a couple of style properties to all A tags whose class is 'menu')
var styleArray = new Array(); styleArray['textAlign'] = 'right'; styleArray['paddingRight'] = '3px'; styleArray['fontFamily'] = 'courier new'; setTagStyleByAttr('A','class','menu',styleArray);
Outputs
(sets a couple of style properties to all A tags whose class is 'menu')
Source Code
download sourcefunction setTagStyleByAttr(strobj,stratt,strval,arrstyle){ var objs = document.getElementsByTagName(strobj); for(no=0;no<objs.length;no++){ if(objs[no].getAttribute(stratt)==strval){ for ( keyVar in arrstyle ) { valVar = arrstyle[keyVar]; eval ('objs[no].style.'+keyVar+'="'+valVar+'";'); } } } }
No comments. Be the first!