Forum Moderators: open

Message Too Old, No Replies

document.getElementById('gallery').getElementsByTagName("title").style

         

webaster

1:05 am on Mar 13, 2005 (gmt 0)

10+ Year Member



document.getElementById('gallery').getElementsByTagName("title").style.color="#ffffff";

is this possible?

Bernard Marx

2:06 am on Mar 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



.getElementsByTagName("title") returns a collection (it may be length zero, if there are none).

If you want to change the color of all the elements you need to loop through the collection:

var titles = document.getElementById('gallery').getElementsByTagName("title");
for(var k=0;k<titles.length;k++)
titles[k].style.color = '#ffffff';


This is a very poor example, because (X)HTML docs should contain only one <title> element.
The one in the <head>.

webaster

2:06 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



I meant the title tags in
eg

<a href="" title="">
<span title="">

webaster

2:08 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



<a href="" title="">LInk</a>
<span title="">Specificstyles</span>

Bernard Marx

2:11 pm on Mar 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



They're not tags, but attributes - that's fundamental.
You can't set the style of an attribute.
What is it that you want to do?

webaster

2:21 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



there is an excellent example of a dhtml tooltip manager which styles the titel attribute by means of DOM and javascript. see example.
[css.experiments.severnsolutions.co.uk...]

the javascript

[css.experiments.severnsolutions.co.uk...]

Bernard Marx

2:30 pm on Mar 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Very nice, but it isn't "styling the title attribute".

webaster

2:44 pm on Mar 13, 2005 (gmt 0)

10+ Year Member



indirectly of course