获取<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>
可以发牢骚,但是必须要努力奋斗!