javascript - 使用javascript代码从HTML的select标签中读取选定的值

标签 javascript html

我的 HTML 代码如下:

 <div id="detail">
    <div class="d_left">
    Page <strong>1</strong> of 107
    </div>
    <div class="d_center">
    <table>
    <tr>
    <td><a href="#">Previous</a> | <a href="#">Next</a>
    <img src="/webProject/store/images/arrow.png" align="absmiddle" alt="">
    </td></tr></table>
    </div>
    <div class="d_right">
    Sort by:
     <select name="featured" size="1" id="item1">
          <option>Featured Items1</option>
          <option>Featured Items2</option>
          <option>Featured Items3</option>
          <option>Featured Items4</option>
        </select>
    </div>
</div>

现在,我想从 <select name="featured" size="1" id="item1"> 中读取选定的值. 我如何使用 JavaScript 执行此操作?

最佳答案

document.getElementById("item1").value;

关于javascript - 使用javascript代码从HTML的select标签中读取选定的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6675125/

相关文章:

javascript - 将比屏幕宽的 div 中心与屏幕中心对齐

javascript - 如何停止编写链码?

html - 水平菜单 - IE 中的空白

javascript - 添加新输入点击功能删除之前的输入内容

Javascript-将数组中的值匹配到变量的子字符串

javascript - 当用户点击 map 时查看详细信息

javascript - 如何更改传单上缩放按钮的不透明度?

javascript - 在html中播放wav音频文件的移动波形

javascript - PHP:同时返回二维数组和单个变量

javascript - js 文件中的 Prestashop Smarty 语言字符串