获取<a>标签值</a>的标签值及更改

html代码:

<a id="catelogue_div1_h5" onclick="catelogue_div1(event)">隐藏</a>

javascript代码:

<script type="text/javascript">
     function catelogue_div1(e){
         var x=document.getElementById('catelogue_div1_h5');
         var catelogue_div1=document.getElementById('catelogue_div1');
         if(x.innerHTML=="隐藏"){           //通过.innerHTML获取
             catelogue_div1.style.display="none";  
             x.childNodes[0].data ="显示";   //通过.childNodes[0].data更改标签值
         }else if(x.innerHTML=="显示"){
             catelogue_div1.style.display="block"; 
             x.childNodes[0].data ="隐藏";
         }
     }
</script>

 

posted @ 2015-01-27 20:46  记忆书签  阅读(5284)  评论(0编辑  收藏  举报