Use at own risk. Programs haven't been thoroughly tested.

function: removeTagChildsByAttr

Removes 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

Example

Usage
removeTagChildsByAttr('A','class','menu')

Outputs
(removes all A tags whose class is 'menu')

Source Code

download source
function removeTagChildsByAttr(strobj,stratt,strval){
    var objs = document.getElementsByTagName(strobj);
    for(no=0;no<objs.length;no++){
        if(objs[no].getAttribute(stratt)==strval){
            objs[no].parentNode.removeChild(objs[no]);
        }
    }
}

Add comment

» Currently away on vacation. I can reply your message the 24th of July 2008. Please post anyway and check back then. Thank you!

for syntax highlighting

[CODE="Javascript"]
your_code_here();
[/CODE]

Replace "Javascript"
with "php", "text", etc.
code (to make sure you are not a spammer)

Comments

No comments. Be the first!