Forum How do I...?

I can't change the style of an element (javascript)

efra
I have an xml file where I need to add some elements, table elements to be precise. Then change their style and format them as accordingly.

I can successfully insert the elements(The content is processed and exists in the generated PDF). However I am facing a trouble when I try to change the style of the newly added elements.

When I type in the tags manually I can style them with CSS. However when I use javascript to insert the tags, the same stylesheet doesn't style them!

By the way, the content is inserted before the style is applied.

Is there some kind of sequence that I should be aware of?

Thank you in advance.

mikeday
Could this be a namespace issue? For example, this works for me:
<style>
p.foo { color: red }
</style>
<script>
window.onload = function() {
    var p = document.createElement("p");
    p.textContent = "Hello, world!";
    p.className = "foo";
    document.body.appendChild(p);
};
</script>
efra
Wow! Right on point. That actually worked like a charm. Thank you.