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!!

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?

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

ahh great, it works now. thanks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.