0

Hi all

I need a javascript code that removes all the title="*" attributes in a page, where the star (*) represents a wildcard for the content of the title attribute. So the following would occur:

<a href="#" title="test">test</a>
would be replaced with
<a href="#">test</a>

just like:

<a href="#" title="">test</a>
would be replaced with:
<a href="#">Test</a>

I know there is a function in javascript called match, but i have no idea how to write the reg expression that would work like the above example.

thanks in advance!!

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by MDGM
0

iv just found a function called removeattribute and am trying to figure out how to apply this to every element on the page.

So far I have this:

for(var i=0; document.all < document.all.length; i++) {
    document.all[i].removeAttribute("title");
}

but its not making any changes to the page.
Can anybody shed some light?

Edited by Nick Evan: Fixed formatting

0

Hi there,

I think the script you wrote is being executed before any of the elements are actually created. Perhaps modifying it like this will have a better effect.

window.onload = function(){
	for(var i=0;i<document.all.length;i++) {
		document.all[i].removeAttribute("title");
	}
}

I replaced the document.all with i by the way.

Hope this helps,

Traevel

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.