zoukankan      html  css  js  c++  java
  • 获取select标签选中的值的三种方式

    var obj = document.getElementByIdx_x(”testSelect”); //定位id

    var index = obj.selectedIndex; // 选中索引

    var text = obj.options[index].text; // 选中文本

    var value = obj.options[index].value; // 选中值

    jQuery中获得选中select值

    第一种方式
    $('#testSelect option:selected').text();//选中的文本

    $('#testSelect option:selected').val();//选中的值

    $("#testSelect ").get(0).selectedIndex;//索引

    第二种方式
    $("#tesetSelect").find("option:selected").text();//选中的文本
    …….val();
    …….get(0).selectedIndex;

    内容转自:http://blog.csdn.net/foart/article/details/6614829

  • 相关阅读:
    h5基本单词
    啦啦
    新内容
    Apache.PHP和MySQL的配置
    static关键字
    访问控制
    PHP Session
    PHP cookie
    全局空间
    使用use操作符导入/使用别名
  • 原文地址:https://www.cnblogs.com/Nicolasap/p/6649720.html
Copyright © 2011-2022 走看看