1

当人们单击它们时,我正在尝试向选项卡添加和删除类。这就是我现在所拥有的,它绝对没有任何作用..!

<script> 
<!-- 
function toggleClasses() {
   tab1 = document.getElementById("tab1");
   tab2 = document.getElementById("tab2");
   tab3 = document.getElementById("tab3");
   tab4 = document.getElementById("tab4");

   tab1.removeClassName("bstTabSelected").addClassName("bstTab");
   tab2.removeClassName("bstTabSelected").addClassName("bstTab");
   tab3.removeClassName("bstTabSelected").addClassName("bstTab");
   tab4.removeClassName("bstTabSelected").addClassName("bstTab");

}
//--> 
</script>

我打电话给它:

<a href="#" id="tab1" onclick="toggleClass()" class="bstTabSelected" clicktoshow="tab1" clicktohide="tab2,tab3,tab4">Tab 1</a>

我似乎无法弄清楚..谢谢!

4

1 回答 1

0

You function is named toggleClasses (plural) where your click event calls toggleClass (singular)

EDIT

Are you using Firefox and Firebug? FBJS doesn't ovewrite the console, which is super handy. Make sure your function is running at all

function toggleClasses()
{
  console.log( 'Hello from toggleClasses!' );
}
于 2010-12-02T20:09:35.167 回答