Search code examples
jquerycssxmlcdata

Changing the inline style of a CDATA font tag via JavaScript


I have an xml file that is loaded via jquery to populate a jQuery mobile list. Everything is working great except I need to change the inline styling of the font color on the CDATA font tag dynamically within the page.

I have tried document.getElementById("font").style.color = "#000000"; and I have also tried to override the styling via the external CSS using !important.

Neither of those are working. Does anyone have any other suggestions?


Solution

  • Of course getElementById() is never going to work as it only targets the id attribute of an element. Can you just give font an id (like "myID") and target that instead?

    document.getElementById("myID").style.color = "#000";
    

    Or by using jQuery it would simply be $('#myID').css('color','#000');


    As per comments, instead of using an id, targeting the element directly is just as valid...

    $('font').css('color','#000');