View Full Version : Swap bullet style on Click

01-04-2010, 06:05 PM
I'm stuck on how to change the bullet style for my ul tags when they have been clicked.

I have a list with bullet styles set to an image. When I click on them, to show the submenu (this is a modified accordian dd menu), I want the original main menu bullet images to change to a different image.

How can I do this?

Here's the link:

Basically, I want the little red + to change to white (but they're images), when you click on one of them.

Thanks in advance!

For my HTML:

<div id="masterdiv">
<ul class="menutitle"><li><div class="menutitle" onclick="SwitchMenu('sub1')">Commercial Products</div>
<span class="submenu" id="sub1">
<ul id="submenuID">
<li><a href="new.htm">Fire<i>Stop</i> Detection</a></li>
<li><a href="hot.htm">Machinery Space (Engine Room) Suppression</a></li>
<li><a href="revised.htm">Galley Suppression</a></li></ul>
<li><div class="menutitle" onclick="SwitchMenu('sub2')">Request for Quote</div>
<span class="submenu" id="sub2">
<ul id="submenuID">
<li><a href="notice.htm">Fire<i>Stop</i> Design Guide</a></li>
<li><a href="faqs.htm">H Engineered Design Guide</a></li></ul>

<!-- end nav menu --></div>

Javascript (which is freeware from Dynamicdrive.com)

<script type="text/javascript">
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
function SwitchMenu(obj){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
el.style.display = "block";
el.style.display = "none";
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(off set, end))
return returnvalue;
function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display ="block"
function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display= ="block"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
if (persistmenu=="yes" && document.getElementById)

And my CSS for my MenuTitle & SubMenu

<style type="text/css">
font-weight:bold;/* */
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
list-style-image: url(images/bullet.jpg);
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
width: 250px;
list-style-type: none;