title: Change background on hover and remove it on hover (with a color change on click complication)
body: <p>I've been experimenting with two different ways of highlight a set (class) of span tags on hover (from here this thread:  <a href="https://stackoverflow.com/questions/3741157/change-background-color-on-mouseover-and-remove-it-after-mouseout">Change background color on mouseover and remove it after mouseout</a>):</p>
  
  <p>1)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $('.pagination_per_page').bind("mouseover", function(){
          var color = $(this).css("background-color");
          $(this).css("background", '#FFFF00');
          $(this).bind("mouseout", function(){
          $(this).css("background", color);
          })
      })
  })
  &lt;/script&gt;
  </code></pre>
  
  <p>2) suppose to be better</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $('.pagination_per_page').hover(
              function(){
                  var $this = $j(this);
                  $this.data('bgcolor', $this.css('background-color')).css('background-color', '#FFFF00');
              },
              function(){
                  var $this = $j(this);
                  $this.css('background-color', $this.data('bgcolor'));
              }
          );
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>Both of those work fine.   My problem is that while the hover is highlighting the items in yellow, on-click I'm setting the background to green (to indicate which level of pagination items per page is being used).  Of course when the hover state ends, both scripts are reverting back to the original state before the hover so my green background color (to indicated the selected pagination level) is being replaced by what the background was before the hover event started.</p>
  
  <pre><code>&lt;span id="pagination_per_page_10" class="pagination_per_page" onClick="pagination_per_page('10');" style="cursor:pointer;"&gt;&amp;nbsp;10&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  &lt;span id="pagination_per_page_20" class="pagination_per_page" onClick="pagination_per_page('20');" style="cursor:pointer;"&gt;&amp;nbsp;20&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  &lt;span id="pagination_per_page_30" class="pagination_per_page" onClick="pagination_per_page('30');" style="cursor:pointer;"&gt;&amp;nbsp;30&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  &lt;span id="pagination_per_page_40" class="pagination_per_page" onClick="pagination_per_page('40');" style="cursor:pointer;"&gt;&amp;nbsp;40&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  &lt;span id="pagination_per_page_50" class="pagination_per_page" onClick="pagination_per_page('50');" style="cursor:pointer;"&gt;&amp;nbsp;50&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  &lt;span id="pagination_per_page_75" class="pagination_per_page" onClick="pagination_per_page('75');" style="cursor:pointer;"&gt;&amp;nbsp;75&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  &lt;span id="pagination_per_page_100" class="pagination_per_page" onClick="pagination_per_page('100');" style="cursor:pointer;"&gt;&amp;nbsp;100&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  &lt;span id="pagination_per_page_ALL" class="pagination_per_page" onClick="pagination_per_page('ALL');" style="cursor:pointer;"&gt;&amp;nbsp;ALL&amp;nbsp;&lt;/span&gt;&amp;nbsp;
  
  &lt;script type="text/javascript"&gt;
      pagination_per_page = function(e) {
      $j('#pagination_per_page_' + e).css("background-color", '#00FF00');
  
      // set a cookie with the user desired pagination items per page
      // call some ajax to reload the list
      // etc.
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Is it possible to modify either script to restore a different color than the original if a click has occured?  I'm not that great with Javascript but could the pagination_per_page function change the variable contents of the 2nd .over function from above so the mouse-out color restore will just change it to the green the pagination_per_page function is setting the span to onclick()?</p>
  
  <p>Thanks - much apprecaited!</p>