我的表格宽度高度是用百分比来控制的 我现在想要其中某个单元格的宽度高度(px)我应该怎么弄

解决方案 »

  1.   

    <a href="http://topic.csdn.net/t/20060223/11/4572508.html">参考</a>
      

  2.   

    <table style="width: 500px; height: 100px; border: solid 1px black;">
        <tr style=" height:20%;">
            <td style="width: 20%; border: solid 1px black;">
                <input type="text" onclick="getPar(this)" />
            </td>
            <td style="width: 80%; border: solid 1px black;">
                <input type="text" onclick="getPar(this)" />
            </td>
        </tr>
            <tr style=" height:80%;">
            <td style="width: 20%; border: solid 1px black;">
                <input type="text" onclick="getPar(this)" />
            </td>
            <td style="width: 80%; border: solid 1px black;">
                <input type="text" onclick="getPar(this)" />
            </td>
        </tr>
    </table><script type="text/javascript">
        function getPar(thisObj) {
            var parentObj = thisObj.parentNode;
            thisObj.value = "width:" + parentObj.offsetWidth + " height:" + parentObj.offsetHeight;
        }
        
    </script>楼主可以试试这个.