zoukankan      html  css  js  c++  java
  • getElementById在IE和FireFox浏览器中的区别

    JS代码:

    function GoToList()
    {
        //var partID=document.getElementById('SelectClassId').selectedOptions[0].value;//此语句在IE中无法正常取值,但在非IE中正常
        //以下为通用方法:
        var a=document.getElementById("SelectClassId");//从document对象中,获取select标签
        var partID=a.options[a.selectedIndex].value;//select标签获取的值其实是一个数组--a.options[]; 然后,选定项的下标是--a.selectedIndex    
        //document.write(partID);
        var Url="SelectPart.asp?Pid="+partID;    window.location.href=Url;
    } 
    

    HTML代码:

    <select id="SelectClassId" name="SelectClassId">
        <option value="1">分类一</option>
        <option value="2">分类二</option>
        <option value="3">分类三</option>
        <option value="4">分类四</option>
        <option value="5">分类五</option>
    </select>
    <input type="button" id="Sure" name="Sure" value="确认" onclick="GoToList()" />
     



  • 相关阅读:
    TCP和UDP区别
    session和cookie的区别
    2019 腾讯正式批笔试题题解
    modCount干嘛的
    分布式系统唯一ID生成方案汇总
    分布式数据库名词
    快手第一题
    南柯一梦
    349. 两个数组的交集
    synchronized锁优化
  • 原文地址:https://www.cnblogs.com/xieyunc/p/9126508.html
Copyright © 2011-2022 走看看