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