上代码...请问我 document.getElementByName("show")可以取到c标签对吧 但现在我想取a标签的style元素的值 我ok方法应该怎么写    <c id =<%= i%> name="show">
       <b id=<%=m%>>
           <a href="#" style="abc">
           </a>
       </b>
   </c><script type=text/javascript>
    function ok() {
         document.getElementByName("show").    }
</script>

解决方案 »

  1.   

     <a id="a1" href="#" style="abc"></a>
    document.getElementById("a1").style.display = 'none';
      

  2.   

        function ok() {
             document.getElementByName("show")[0].style
        }style是个对象访问他的属性可以 xx.style.width 这个样子
      

  3.   

    document.getElementsByName("show")[0].getElementsByTagName("a")[0].getAttribute('style')
      

  4.   

    回三楼
    我javascrpt里声明
    var obj =""
    function ok() {
          alert("sadasd");
       obj=document.getElementsByName("show")[0].getElementsByTagName("a")[0].getAttribute('style');
       alert(obj);    }出错 alert弹不出来 对象应该没取到 你再给看看把
      

  5.   


       <c name="show">
           <b>
               <a href="#" style="abc">
               </a>
           </b>
       </c><script type=text/javascript>
        function ok() {
            obj=document.getElementsByName("show")[0].getElementsByTagName("a")[0].getAttribute('style');
    alert(obj);
        }
    ok()
    </script>