<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 概述 value用于大部分表單元素的內容獲取(option除外). type可以獲取input標簽的類型(輸入框或復選框等). disabled 禁用屬性. checked復選框選中屬性. selected下拉菜單選中屬性. ## 說明 當html中的標簽的屬性,只有一個值的時候,它的屬性值是布爾類型的.只有上面列的后三個. ``` <body> <input type="button" value="禁用" id="btn"> <input type="button" value="啟用" id="btn1"> <input type="text" name="" id="txt"> <script> var btn = document.getElementById('btn'); btn.onclick = function () { txt = document.getElementById('txt'); txt.disabled = true; } var btn1 = document.getElementById('btn1'); btn1.onclick = function () { txt = document.getElementById('txt'); txt.value = 'hello'; } </script> ``` ## 瀏覽器打開后給所有input賦值,點擊按鈕獲取所有值并用|分割. ``` <body> <input type="button" value="獲取" id="btn"> <input type="text"> <input type="text"> <input type="text"> <input type="text"> <input type="text"> <input type="text"> <script> var inputs = document.getElementsByTagName('input'); for (let i = 0; i < inputs.length; i++) { if (inputs[i].type === 'text') { inputs[i].value = i; } } var btn = document.getElementById('btn'); var str = ''; btn.onclick = function () { for (let i = 0; i < inputs.length; i++) { if (inputs[i].type === 'text') { str += inputs[i].value + '|'; } } console.log(str.substr(str,str.length-1)); } </script> ``` 優化,因為字符串是不可變的.所以直接大量拼接很占用性能. ``` btn.onclick = function () { for (let i = 0; i < inputs.length; i++) { if (inputs[i].type === 'text') { arr.push(inputs[i].value) } } console.log(arr.join('|')); } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看