Is it possible to have a single function controlling multiple buttons
for which the color of each can be individually switched back and
forth between two different colors? The following code works fine for
a single button, but for more than one button it fails. The function
change() needs to be able to distinguish between buttons. Passing the
button that is clicked to the function would work, is that possible
somehow?

        <script type="text/javascript">
          var check = 0;
          function change() {
            var button = document.getElementById('a_button');
            if ( check == 0 ) {
              button.style.background="green";
              check = 1;
            } else {
              button.style.background="red";
              check = 0;
            }
          }
        </script>

        <div class="navbutton" id="a_button" onclick="change();">
          <span class="navbutton_text">button 1</span>
        </div>

        <div class="navbutton" id="a_button" onclick="change();">
          <span class="navbutton_text">button 2</span>
        </div>

--~--~---------~--~----~------------~-------~--~----~
--
You received this because you are subscribed to the "Design the Web with CSS" 
at Google groups.
To post: [email protected]
To unsubscribe: [email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to