我有兩個列表框設置具有多個屬性,並添加項目從第一到第二,我不希望在第二個列表框中的選擇。removeAttr(「selected」)在IE6中顯示錯誤
我寫了這樣的代碼
$("#<%=lbCommcatTo.ClientID%> option").removeAttr("selected");
它工作在IE7,但不是在IE6。任何人都可以請給我一個解決方案?
的HTML是
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td width="45%">
<div style="height: 230px;width: 234px; overflow: auto; border: solid 1px #c1c1c1" id="dvLeft" runat="server">
<select id="lbCommcatFrom" runat="server" style="height:790px;" multiple name="lbCommcatFrom" class="ContentTextNormal">
</select>
</div>
</td>
<td width="10%" align="center">
<div style="border: solid 1px #6E6E6E; width: 20px; height: 20px; padding-top: 4px; text-align: center; margin-bottom: 5px; background-color: #CECFBE; cursor: pointer" title="Add to List" id="imgMoveRight" class="clsArrow">
</div>
<div style="border: solid 1px #6E6E6E; width: 20px; height: 20px; padding-top: 4px; text-align: center; background-color: #CECFBE; cursor: default" title="Remove from List" id="imgMoveLeft" class="clsArrow">
</div>
</td>
<td width="45%">
<div style="height: 230px;width: 234px; overflow: auto; border: solid 1px #c1c1c1" id="dvRight" runat="server">
<select id="lbCommcatTo" runat="server" style="height:230px;width:234px" multiple name="lbCommcatTo" class="ContentTextNormal">
</select>
</div>
</td>
</tr>
</table>
和腳本是這樣的
$("#imgMoveRight").click(function(){
$("#<%=lbCommcatFrom.ClientID%> option:selected").appendTo("#<%=lbCommcatTo.ClientID%>");
if($("#<%=lbCommcatFrom.ClientID%> option").length == 0)
{
$("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-x","hidden");
$("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-y","hidden");
$("#<%=lbCommcatFrom.ClientID%>").css("width","234px");
$("#<%=lbCommcatFrom.ClientID%>").css("height","230px");
$(this).css("cursor","default");
}
else
{
if($("#<%=lbCommcatTo.ClientID%> option").length > 0)
{
$("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-x","scroll");
$("#<%=lbCommcatTo.ClientID%>").css("width","465");
$("#<%=lbCommcatFrom.ClientID%>").css("width","465");
if($("#<%=lbCommcatTo.ClientID%> option").length > 15)
{
$("#<%=lbCommcatTo.ClientID%>").css("height",$("#<%=lbCommcatTo.ClientID%> option").length * 18);
$("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-y","scroll");
}
else
{
$("#<%=lbCommcatTo.ClientID%>").css("height","230");
$("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-y","hidden");
}
$("#imgMoveLeft").css("cursor","pointer");
}
}
**$("#<%=lbCommcatTo.ClientID%> option").removeAttr("selected");**
});
$("#imgMoveLeft").click(function(){
$("#<%=lbCommcatTo.ClientID%> option:selected").appendTo("#<%=lbCommcatFrom.ClientID%>");
$("#<%=lbCommcatFrom.ClientID%>").css("width","465");
if($("#<%=lbCommcatTo.ClientID%> option").length == 0)
{
$("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow","scroll");
$("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-x","hidden");
$("#<%=lbCommcatTo.ClientID%>").parent().css("overflow-y","hidden");
$("#<%=lbCommcatTo.ClientID%>").css("width","232px");
$("#<%=lbCommcatTo.ClientID%>").css("height","230px");
$(this).css("cursor","default");
}
else
{
if($("#<%=lbCommcatFrom.ClientID%> option").length > 0)
{
$("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-x","scroll");
if($("#<%=lbCommcatFrom.ClientID%> option").length > 15)
{
$("#<%=lbCommcatFrom.ClientID%>").css("height",$("#<%=lbCommcatFrom.ClientID%> option").length * 16);
$("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-y","scroll");
}
else
{
$("#<%=lbCommcatFrom.ClientID%>").css("height","230");
$("#<%=lbCommcatFrom.ClientID%>").parent().css("overflow-y","hidden");
}
$("#imgMoveRight").css("cursor","pointer");
}
}
**$("#<%=lbCommcatFrom.ClientID%> option").removeAttr("selected");**
});
什麼錯誤? – Justin808 2010-10-25 07:40:38
腳本錯誤如下所示:Couldnot set selected the property.Unspecified error – Pooja 2010-10-25 07:45:47