<button id="g80sy"></button>
  • <abbr id="g80sy"></abbr>
  • <button id="g80sy"></button>
    <rt id="g80sy"><delect id="g80sy"></delect></rt>
  • jquery獲取input中的值

    程序猿 2021-03-10 21:50:23 3075瀏覽 加載中

    如何用javascript獲取input輸入框中的值,js/jq通過name、id、class獲取input輸入框中的value

     <input type="text" name="one" id="two" class="three">

    一、javascript獲取input輸入框中的值

    通過 name

    var text = document.getElementById("one").value

    通過 id

    var text = document.getElementById("two").value

    通過 class

    document.getElementsByClassName("three")[0].value

    二、jquery獲取input輸入框中的值

    通過 name

    var text = $('input[name="one"]').val();

    通過 id

    var text = $('#two').val();

    通過 class

    var text = $('.three').val();


    標簽:
    最后修改:2025-06-25 22:38:53

    非特殊說明,本博所有文章均為博主原創。

    主站蜘蛛池模板: 油尖旺区| 阿尔山市| 新龙县| 牡丹江市| 治县。| 磐安县| 鸡泽县| 昔阳县| 古交市| 枣庄市| 安宁市| 扶余县| 池州市| 岳阳县| 龙岩市| 和静县| 梁平县| 高邮市| 闵行区| 合水县| 云和县| 达州市| 东乌珠穆沁旗| 沾化县| 新平| 四平市| 成都市| 四子王旗| 平顶山市| 柳江县| 利辛县| 曲靖市| 马山县| 永丰县| 濉溪县| 苍南县| 桦甸市| 拉孜县| 浦城县| 格尔木市| 青阳县|