A
Alvaro G Vicario
I'm writing a small script to scan an HTML document and append a <span
class="foo">Bar</span> node after each item with certain class name.
My script works fine in Gecko but IE has a serious issue: the CSS style
defined in an external sheet for span.foo is not applied. The generated
HTML shows the correct attribute has been inserted (I can see it with an
old "View Partial Source" hack I've kept for years). Thank you for any
hint.
Here's the relevant code:
// obj is an array with nodes
for(var i=0; i<obj.length; i++){
// Create the <span>
var span=document.createElement('span');
span.setAttribute('class', 'foo';
// Creamos <span>'s content
var txt=document.createTextNode('Bar');
// Compose <span>
span.appendChild(txt);
// Insertamos <span> in document
if(obj.nextSibling){
obj.parentNode.insertBefore(span, obj.nextSibling);
}else{
obj.parentNode.appendChild(span);
}
}
class="foo">Bar</span> node after each item with certain class name.
My script works fine in Gecko but IE has a serious issue: the CSS style
defined in an external sheet for span.foo is not applied. The generated
HTML shows the correct attribute has been inserted (I can see it with an
old "View Partial Source" hack I've kept for years). Thank you for any
hint.
Here's the relevant code:
// obj is an array with nodes
for(var i=0; i<obj.length; i++){
// Create the <span>
var span=document.createElement('span');
span.setAttribute('class', 'foo';
// Creamos <span>'s content
var txt=document.createTextNode('Bar');
// Compose <span>
span.appendChild(txt);
// Insertamos <span> in document
if(obj.nextSibling){
obj.parentNode.insertBefore(span, obj.nextSibling);
}else{
obj.parentNode.appendChild(span);
}
}