本文介绍了jQuery的下拉列表中更改事件不火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写Asp.Net MVC应用程序和whant实现级联下拉列表的功能,但我用jQuery改变事件的问题。
我在哪里错了?
使用Javascript:
<脚本的charset =UTF-8TYPE =文/ JavaScript的LANGUAGE =JavaScript的SRC =<%= Url.Content(〜/内容/ jQuery的-1.4.1.js)%>>< / SCRIPT>
<脚本的charset =UTF-8TYPE =文/ JavaScript的LANGUAGE =JavaScript的>
$(文件)。就绪(函数(){
$(#ddlCategories),变化(函数(){警报(成功了!);});
});
< / SCRIPT>
MVC:
<%= Html.DropDownList(CategoriesId(的SelectList)ViewData的[CategoriesList],新{ID =ddlCategories})%GT;
<%= Html.DropDownList(ModelId(的SelectList)ViewData的[ModelsList],新{ID =ddlModels})%GT;
HTML
<选择名称=CategoriesIdID =ddlCategories>
<期权价值=1> Thermage热绍尔塔岛医疗< /选项>
<期权价值=2>与Syneron公司LT; /选项>
<期权价值=59>&德卡LT; /选项>
< /选择>
<选择名称=ModelIdID =ddlModels>
<期权价值=1> Thermage热NXT RF< /选项>
<期权价值=2> Thermacool TC< /选项>
< /选择>
解决方案
正常工作,请参见 。你确定你没有任何其他的JavaScript错误?
I write Asp.Net MVC application and whant to realize cascading drop down lists functionality, but I have problem with jQuery change event.Where am I wrong?
Javascript:
<script charset="utf-8" type="text/javascript" language="javascript" src="<%= Url.Content("~/Content/jquery-1.4.1.js") %>"></script>
<script charset="utf-8" type="text/javascript" language="javascript">
$(document).ready(function () {
$("#ddlCategories").change(function () { alert("It worked!"); });
});
</script>
MVC:
<%=Html.DropDownList("CategoriesId", (SelectList)ViewData["CategoriesList"], new { Id = "ddlCategories" })%>
<%=Html.DropDownList("ModelId", (SelectList)ViewData["ModelsList"], new { Id = "ddlModels" })%>
HTML:
<select name="CategoriesId" id="ddlCategories">
<option value="1">Thermage Solta Medical</option>
<option value="2">Syneron</option>
<option value="59">Deka</option>
</select>
<select name="ModelId" id="ddlModels">
<option value="1">Thermage NXT RF</option>
<option value="2">Thermacool TC</option>
</select>
解决方案
works fine, see here. Are you sure that you don't have any other javascript errors?
这篇关于jQuery的下拉列表中更改事件不火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!