<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

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

    主站蜘蛛池模板: 平顶山市| 米泉市| 芷江| 长武县| SHOW| 法库县| 绵竹市| 文登市| 昌乐县| 富裕县| 三河市| 万全县| 贵港市| 卓资县| 漳平市| 容城县| 崇明县| 禹州市| 防城港市| 江津市| 久治县| 新津县| 通城县| 富裕县| 广河县| 察雅县| 同江市| 宜黄县| 贺兰县| 韶山市| 永福县| 娄烦县| 肥东县| 南川市| 剑河县| 平江县| 江达县| 新泰市| 博爱县| 邢台市| 尼勒克县|