martinS
02-05-2009, 05:55 PM
1) Script Title: Anylink CSS Menu
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm
3) Describe problem: I am hoping someone can help with this.
I am attempting to add or remove items from a menu, actually as a result of an ajax request. The following code is just to demonstrate how I attempt this. Each <li> tag is given an id, and whilst this code works the removal of an item has no effect on the size of the shadow, and adding an item fails to apply the correct style:
<!--1st anchor link and menu -->
<p><a href="http://www.dynamicdrive.com" class="anchorclass" rel="submenu1">Default Example</a></p>
<div id="submenu1" class="anylinkcss">
<ul>
<li id="list11"><a href="http://www.dynamicdrive.com/">Dynamic Drive</a></li>
<li id="list12"><a href="http://www.cssdrive.com">CSS Drive</a></li>
<li id="list13"><a href="http://www.javascriptkit.com">JavaScript Kit</a></li>
<li id="list14"><a href="http://www.codingforums.com">Coding Forums</a></li>
<li id="list15"><a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a></li>
</ul>
</div>
<!--2nd anchor link and menu -->
<p><a href="http://www.dynamicdrive.com" class="anchorclass" rel="submenu2">Default Example</a></p>
<div id="submenu2" class="anylinkcss">
<ul>
<li id="list21"><a href="http://www.dynamicdrive.com/">Dynamic Drive</a></li>
<li id="list22"><a href="http://www.cssdrive.com">CSS Drive</a></li>
<li id="list23"><a href="http://www.javascriptkit.com">JavaScript Kit</a></li>
<li id="list24"><a href="http://www.codingforums.com">Coding Forums</a></li>
<li id="list25"><a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a></li>
</ul>
</div>
<script type="text/javascript">
anylinkcssmenu.init("anchorclass")
//to delete an element (but the shadow size remains the same)
var el = document.getElementById('list12');
el.parentNode.removeChild(el);
//to add an element (but the style is lost)
var parent = document.getElementById('submenu2');
var newDiv = document.createElement('li');
newDiv.setAttribute('id', 'list26');
newDiv.innerHTML = "<a href='http://www.javascriptkit.com/jsref/'>Another JavaScript Reference</a>";
parent.appendChild(newDiv);
</script>
Any help would be appreciated.
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm
3) Describe problem: I am hoping someone can help with this.
I am attempting to add or remove items from a menu, actually as a result of an ajax request. The following code is just to demonstrate how I attempt this. Each <li> tag is given an id, and whilst this code works the removal of an item has no effect on the size of the shadow, and adding an item fails to apply the correct style:
<!--1st anchor link and menu -->
<p><a href="http://www.dynamicdrive.com" class="anchorclass" rel="submenu1">Default Example</a></p>
<div id="submenu1" class="anylinkcss">
<ul>
<li id="list11"><a href="http://www.dynamicdrive.com/">Dynamic Drive</a></li>
<li id="list12"><a href="http://www.cssdrive.com">CSS Drive</a></li>
<li id="list13"><a href="http://www.javascriptkit.com">JavaScript Kit</a></li>
<li id="list14"><a href="http://www.codingforums.com">Coding Forums</a></li>
<li id="list15"><a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a></li>
</ul>
</div>
<!--2nd anchor link and menu -->
<p><a href="http://www.dynamicdrive.com" class="anchorclass" rel="submenu2">Default Example</a></p>
<div id="submenu2" class="anylinkcss">
<ul>
<li id="list21"><a href="http://www.dynamicdrive.com/">Dynamic Drive</a></li>
<li id="list22"><a href="http://www.cssdrive.com">CSS Drive</a></li>
<li id="list23"><a href="http://www.javascriptkit.com">JavaScript Kit</a></li>
<li id="list24"><a href="http://www.codingforums.com">Coding Forums</a></li>
<li id="list25"><a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a></li>
</ul>
</div>
<script type="text/javascript">
anylinkcssmenu.init("anchorclass")
//to delete an element (but the shadow size remains the same)
var el = document.getElementById('list12');
el.parentNode.removeChild(el);
//to add an element (but the style is lost)
var parent = document.getElementById('submenu2');
var newDiv = document.createElement('li');
newDiv.setAttribute('id', 'list26');
newDiv.innerHTML = "<a href='http://www.javascriptkit.com/jsref/'>Another JavaScript Reference</a>";
parent.appendChild(newDiv);
</script>
Any help would be appreciated.