浏览 7012 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-03-04
最后修改:2009-03-25
有用到可以看看: /**************************************************************** * Author: Alistair Lattimore * Website: http://www.lattimore.id.au/ * Contact: http://www.lattimore.id.au/contact/ * Errors, suggestions or comments * Date: 30 June 2005 * Version: 1.0 * Purpose: Emulate the disabled attributte for the <option> * element in Internet Explorer. * Use: You are free to use this script in non-commercial * applications. You are however required to leave * this comment at the top of this file. * * I'd love an email if you find a use for it on your * site, though not required. ****************************************************************/ window.onload = function() { if (document.getElementsByTagName) { var s = document.getElementsByTagName("select"); if (s.length > 0) { window.select_current = new Array(); for (var i=0, select; select = s[i]; i++) { if(select.id == "your select id") {[//你的select id select.onfocus = function(){ window.select_current[this.id] = this.selectedIndex; } select.onchange = function(){ restore(this); } emulate(select); [color=red]}[/color]} } } } function restore(e) { if (e.options[e.selectedIndex].disabled) { e.selectedIndex = window.select_current[e.id]; } } function emulate(e) { for (var i=0, option; option = e.options[i]; i++) { if (option.disabled) { option.style.color = "graytext"; } else { option.style.color = "menutext"; } } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-09-23
如果在select 中添加onchange="" 将会无效,请问怎么解决啊·~?如下代码
<select id="s1" onchange="alert(this.selectedIndex);"> <option value="p1" >p1</option> <option value="p2" >P0</option> <option value="p3" >P3</option> <option value="p4" >P4</option> </option> onchange方法被select-option-disabled-emulation.js代码中select.onchange = function(){ restore(this); } 覆盖 |
|
返回顶楼 | |
发表时间:2009-09-23
f0799 写道 如果在select 中添加onchange="" 将会无效,请问怎么解决啊·~?如下代码
<select id="s1" onchange="alert(this.selectedIndex);"> <option value="p1" >p1</option> <option value="p2" >P0</option> <option value="p3" >P3</option> <option value="p4" >P4</option> </option> onchange方法被select-option-disabled-emulation.js代码中select.onchange = function(){ restore(this); } 覆盖 你要使用onchange事件是话,可能只有把select-option-disabled-emulation.js代码换成其它事件类似替代它。可以试试看先... |
|
返回顶楼 | |