|
Posted by Martin Honnen on July 28, 2008, 8:10 am
Please log in for more thread options
Denis McMahon wrote:
> A relative has a web page that they want to work with google checkout,
> so it has to be xhtml, as the google scripts require xhtml.
>
> However, I wish to replace the text content of an id'd span.
>
> In html 4.01, I could do this with the innerhtml property, but that's
> not supported in xhtml.
>
> Any suggestions? I can find examples that show me how to create an
> additional textnode and add text to it, but not ones that show me how to
> update or replace [the content of] an existing textnode.
document.getElementById('spanId').firstChild.nodeValue = 'foo';
However as long as you serve the XHTML document as text/html it should
be no problem at all to use innerHTML, and even if the XHTML is served
as application/xhtml+xml then browsers like Firefox 1.5 and later
support innerHTML for XHTML elements.
--
Martin Honnen
http://JavaScript.FAQTs.com/
|