You mentioned that you wanted to be able to see it when you view the
source - is that important? Because you wont *see* the span element but
the browser will. (I imagine you are doing this for an image replacement
technique in which case not seeing it wouldn't be a big issue). Remember
you need to call the function, for example
<body onload="insertSpan()">
Dustin Diaz wrote:
function insertSpan() {
if ( !document.getElementById || !document.createElement ) {
return;
}
var util = document.getElementById('utilities');
var links = util.getElementsByTagName('a');
for ( i=0;i<links.length;i++ ) {
var span = document.createElement('span');
links[i].appendChild(span);
}
}
Dustin
On 11/1/05, Peter Ottery <[EMAIL PROTECTED]> wrote:
just say i have markup like this:
----------------------------------
<div id ="utility">
<ul>
<li><a href="">List Item</a></li>
<li><a href="">List Item</a></li>
<li><a href="">List Item</a></li>
</ul>
</div>
---------------------------------
and for one reason or another I *dont* have access to the html markup.
Then an intricate design comes along that requires an extra hook (a span
tag) to be inserted inside each <a href></a> tag.
is it possible to use javascript (1) to insert a <span> tag inside each a
href "on the fly" so its not in the markup - but would be there if you were
able to view the rendered source? you know what i mean - dynamically
changing the dom... or something
can you tell i know nothing about javascript? :)
any help appreciated.
cheers, pete
(1) - of course, without javascript list items would still be accessible -
they just wouldnt have the nice design inticacies
******************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************
******************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************