删除Pocket IE上的选择选项 [英] remove select option on Pocket IE
问题描述
嗨
试图删除选择选项的一个或所有元素对于Pocket
Internet Explorer失败。有没有办法做到这一点?
如果is_PIE {
//这在Pocket IE上不起作用
while( opt.length){
opt.remove(0);
}
} else {
#IE 5. +,Moz,FF,Galeon,Opera,Konq
#一次删除所有内容
opt.length = 0;
}
TIA
Stefan
Hi
trying to remove one or all elements of select options fails for Pocket
Internet Explorer. Is there a way to do this?
if is_PIE {
// this does not work on Pocket IE
while (opt.length) {
opt.remove(0);
}
} else {
# IE 5.+, Moz, FF, Galeon, Opera, Konq
# remove everything at once
opt.length = 0;
}
TIA
Stefan
推荐答案
他,他从不吝啬IE口袋,代码完全无效,对任何IE都不应该工作
。 document.YOURFORMNAME.YOURSELECTNAME.options [0] = null
删除第一个选项,依此类推。
Danny
He he, nevermind IE pocket, that code is completely invalid, shouldn''t work
for any IE at all. document.YOURFORMNAME.YOURSELECTNAME.options[0]=null
removes 1st option and so on and so on.
Danny
>
Danny写道:
他,他从不吝啬IE口袋,那个代码完全无效,对任何IE都不应该工作。
发布非感性回复,只能解释
作为混淆的尝试。
大概你认为发布的代码的其他部分是错误的,但是你错了。
document.forms [formname] .elements [selectname] .options.length = 0;
一次性删除所有选择的选项 - 正如OP指示的那样。
对任何IE都可以。 document.YOURFORMNAME.YOURSELECTNAME.options [0] = null
删除第一个选项,依此类推。
He he, nevermind IE pocket, that code is completely invalid, shouldn''t work
for any IE at all.
Posting non-sensical replies to nothing at all can only be interpretted
as an attempt to confuse.
Presumably you think the ''else'' part of the posted code is in error, but
you are wrong.
document.forms[formname].elements[selectname].options.length = 0;
removes all of a select''s options in one go - just as the OP indicated.
for any IE at all. document.YOURFORMNAME.YOURSELECTNAME.options[0]=null
removes 1st option and so on and so on.
-
Rob
--
Rob
Stefan Finzel写道:
Stefan Finzel wrote:
嗨
尝试删除选择选项的一个或所有元素失败for Pocket
Internet Explorer。有没有办法做到这一点?
如果is_PIE {
//这在Pocket IE上不起作用
而(opt.length){
opt.remove (0);
Hi
trying to remove one or all elements of select options fails for Pocket
Internet Explorer. Is there a way to do this?
if is_PIE {
// this does not work on Pocket IE
while (opt.length) {
opt.remove(0);
我没有口袋IE可以玩,但这种语法在IE浏览器中工作正常。
和Firefox。你试过循环选项集合吗?
将每个选项设置为'null?
var i = opt.length;
while(i - ){
opt [1] = null;
}
或
while(opt [0]){
opt [0] = null;
}
或使用removeChild方法?
var i = opt.length;
while(i - ){
opt [i] .parentNode.removeChild(opt [i]);
}
或
var sel = opt [ 0] .parentNode;
while(sel.firstChild){
sel.removeChild(sel.childNodes [0]);
}
或以上的组合?
[...]
-
Rob
I don''t have pocket IE to play with, but that syntax works fine in IE
and Firefox. Have you tried looping through the options collection and
setting each option to ''null?
var i = opt.length;
while ( i-- ){
opt[1] = null;
}
or
while ( opt[0] ){
opt[0] = null;
}
or using the removeChild method?
var i = opt.length;
while ( i-- ){
opt[i].parentNode.removeChild(opt[i]);
}
or
var sel = opt[0].parentNode;
while ( sel.firstChild ){
sel.removeChild(sel.childNodes[0]);
}
or some combination of the above?
[...]
--
Rob
这篇关于删除Pocket IE上的选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!