输出

Display

elements :



示例代码

This is a demo for "disabled" and "elements" attributes of "fieldset" tag.

HTML:

  <fieldset id="fs" disabled>
    <legend>Display</legend>
    <label name="ts">The node below is disabled:</label>
    <p><label><input type=radio name=c value=0 checked> Black on White</label>
    <p><label><input type=radio name=c value=1> White on Black</label>
    <p><label><input type=checkbox name=g> Use grayscale</label>
    <p><label>Enhance contrast <input type=range name=e list=contrast min=0 max=100 value=0 step=1></label>
    <datalist id=contrast>
      <option label=Normal value=0>
      <option label=Maximum value=100>
    </datalist>
  </fieldset>

  <script>
    function output() {
      var e = document.getElementById("fs");
      var re1 = document.getElementById ('result1');
      var re2 = document.getElementById ('result2');
      var re3 = document.getElementById ('result3');
      re1.textContent="";
      re2.textContent="";
      re3.textContent="";
      re1.textContent +="elements length : "+e.elements.length;
      re2.textContent +="elements item(1) : "+e.elements.item(1);
      re3.textContent +="elements namedItem(\"ts\") : "+e.elements.namedItem("ts");
      return false;
    }
  </script>
  <form>
    <input type="button" value="Click" onClick="output()" />
  </form>
  <p>elements : <br>
    <output id="result1"></output><br>
    <output id="result2"></output><br>
    <output id="result3"></output><br>
  </p>