The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Javascript : appendChild
What's the best way to add an <li> with a nested <a> tag to an exisiting <ul>?
More simply, I want to create a structure like this : <li><a href='something'>Click</a></li> from the ground up, and insert it into the ul DOM When I use my method, it works in opera, but not in safari or firefox, however it does not produce any javascript errors, it just doesn't work! Sample code [I've tried several ways...here's one] Code:
var newli = document.createElement('li'); var aHref = document.createElement('a'); aHref.href = 'www.google.com'; var text = document.createTextNode('hello' ); newli.appendChild(aHref); var child = parent_node.firstChild; parent_node.insertBefore(newli, child); parent_node.firstChild.firstChild.appendChild(text); This 'works' as in it inserts a node, but it isn't linked as it should be. I've also tried aHref.setAttribute('href', '#6') ... but doesn't seem to work either. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|