<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 2908瀏覽 加載中

    如何用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-03-26 13:04:51

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

    主站蜘蛛池模板: 天峻县| 济阳县| 称多县| 萝北县| 霍林郭勒市| 大邑县| 衡南县| 桑日县| 平山县| 靖远县| 栾川县| 理塘县| 伊吾县| 奎屯市| 太原市| 遂川县| 永顺县| 光山县| 台湾省| 长沙县| 彭泽县| 安乡县| 通渭县| 湛江市| 陇西县| 新营市| 普陀区| 高唐县| 苍梧县| 南昌市| 建始县| 孟津县| 香港 | 黔东| 塔河县| 阳高县| 郁南县| 梅河口市| 竹溪县| 南城县| 新龙县|