Wednesday Jun 17, 2009

Dynamic CSS changer

Purpose: Dynamically alters the css style class providing hilighting of hyperlinks
Arguments:  id - the dom id reference to the <a> tag
                    condition - boolean passed from the mouseover event used to set

<script language="javascript" type="text/javascript">

function highLight(id, condition) {
  var styleClass = document.getElementById(id).className
  if(condition)
    document.getElementById(id).className = "hilite_"+styleClass;
  else
    document.getElementById(id).className = styleClass.substr(7);
}

</script>

Use with an <a> tag like this

<p class="menu_side" id="menu1"><a href="/page1.html" class="menu_side" id="menu1" onMouseOver="highLight(this.id,true)" onMouseOut="highLight(this.id,false)">Page 1 </a></p>

Comments:

Post a Comment:
Comments are closed for this entry.