我有兩個下拉列表,他們都列出了相同的國家。當用戶在兩個下拉列表中選擇相同的國家時,我想顯示一條警報消息。我怎樣才能使用jQuery?如何使用jquery在c#中顯示alertbox?
<td>
<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True">
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlCountry1" runat="server" AutoPostBack="True">
</asp:DropDownList>
</td>
<script type="text/javascript">
$(document).ready(function() {
$("#<%=ddlCountry.ClientID %>").change(function() {
if ($("#<%=ddlCountry.ClientID%> option:selected").text() == $("#<%=ddlCountry1.ClientID%> option:selected").text())
{
alert("Please select different countries");
}
});
});
</script>
什麼是生成的代碼? C#與此無關。 – 2014-08-28 02:14:40
JQuery和C#沒有關係。你在說什麼?? – 2014-08-28 02:21:48