I try to create some li elements in my XUL Application. Theres only the text of the elements shown, but no list typical bullets and linebreaks.
Example:
Heres the JS Code I use to create the list:
var li = document.createElement('html:li');
var txt = document.createTextNode("only shown as simple text");
li.appendChild(txt);
document.getElementById('someList').appendChild(li);
HTML:
<html:ul id="someList">
<html:li>this is shown in correct list style</html:li>
</html:ul>
I tried 'html:li' and also 'li' but nothing worked.
Any suggestions?
Ok, I figured it out by displaying the reference of the created elements with an alert box...
If you call createElement the XUL Namespace is used. html:foo has no effect. If you want to create an element in a different namespace then the one of XUL you have to use
createElementNS(namespaceURI, qualifiedName)
So the following code works:
var htmlns = "http://www.w3.org/1999/xhtml";
var li = document.createElementNS(htmlns, "li");
var txt = document.createTextNode("text");
li.appendChild(tst);
document.getElementById('someList').appendChild(li);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.