function dowork() {
$("div#TestPart select option[value^=HMT]").addClass("wrappedElement");
}
protected void Page_Load(object sender, EventArgs e)
{
lstDepartment.Attributes.Add("onchange","return dowork();");
}
dowork
是我的JavaScript函數,它觸發的列表框中單擊項,但是當我點擊第一次正常觸發,但是當我點擊第二個時間上的列表項不火。jQuery函數只觸發一次
我不明白是什麼問題。請幫助我,並提前感謝您的建議。
*<div id="sidebar">
</div>
<div id="main">
<div id="header">
<asp:Label ID="lblPackageName" runat="server" Text="Package Name"></asp:Label>
<asp:TextBox ID="txtPackageName" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Sex"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>--Select--</asp:ListItem>
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
<asp:ListItem>Both</asp:ListItem>
</asp:DropDownList>
</div>
<div id="DepPart">
<asp:ListBox ID="lstDepartment" runat="server"
onselectedindexchanged="lstDepartment_SelectedIndexChanged"
AutoPostBack="True"></asp:ListBox>
</div>
<div id="TestPart">
<asp:ListBox ID="lstTest" runat="server"
onselectedindexchanged="lstTest_SelectedIndexChanged" AutoPostBack="True"> </asp:ListBox>
</div>
<div id="SubTestPart">
<asp:ListBox ID="lstSubTest" runat="server"></asp:ListBox>
</div>
<div id="SelectedTestPart">
<asp:ListBox ID="lstSelectedTest" runat="server"></asp:ListBox>
</div>
</div>*
<script type="text/javascript" language="javascript">
function dowork()
{
$("div#TestPart select option[value^=HMT]").addClass("wrappedElement");
}
</script>
顯示你的HTML和JavaScript – gdoron