知道一个表格单元格的id名(是个变量)后,如何获得这个单元格对象的个数,我对象名?比如表格里有几个输入框,几个单选择按钮,但我只清楚单元格的id名,想通过单元格的id名进行查找

解决方案 »

  1.   

    var obj=document.getElementById("id");
    var cellnum=obj.parentElement.cells.length;
      

  2.   

    <td id="in">
      <textarea id='Text1'>Question_Txt</textarea>
      <textarea id='Text1'>Question_Txt</textarea>
      <input name=ScriptStyle id='Radio1' type='radio' />
      <input name=ScriptStyle id='Radio2' type='radio' />
      <input name=ScriptStyle id='Radio3' type='radio' />
      <input id='Checkbox1' checked='checked' type='checkbox' />
      <input id='Checkbox2' checked='checked' type='checkbox' />
      <input id='Checkbox3' checked='checked' type='checkbox' />
      <input id='Checkbox4' checked='checked' type='checkbox' /> 
    </td>
    已知TD的ID号,想取TD容器下的对象个数
      

  3.   

    document.getElementById(yourid).childNodes.length