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()" />
     



  • 相关阅读:
    js中replace的正则替换
    ios沙盒路径
    Android开源框架
    小知识点
    __NSCFConstantString && __NSPlaceholderDictionary
    iq 格式分析
    C 函数
    Xcode报错
    XMPP Server
    H5网站借鉴
  • 原文地址:https://www.cnblogs.com/xieyunc/p/9126508.html
Copyright © 2011-2022 走看看