163----三级联动---实际开发中if嵌套过多,很少使用
2017-01-17 11:38
155 查看
$(document).ready(function(){ $("#select1").change( function() { var id = $("#select1").val(); if(id == 1){ $.get('index.php', null, function(data){ $("#two").empty(); $("#two").append("<select id='select2'><option>请选择</opton><option value='1'>长春</opton><option value='2'>松原</opton></select>"); $("#select2").change( function() { var page = $("#select2").val(); if(page == 1){ $("#three").empty(); $("#three").append("<select><option>双阳</opton><option>农安</opton></select>"); }else{ if(page == 2){ $("#three").empty(); $("#three").append("<select><option>乾安</opton><option>大安</opton></select>"); } } }); }); }else{ $.get('index.php', null, function(data){ $("#two").empty(); $("#two").append("<select id='select3'><option value='1'>大连</opton><option value='2'>旅顺</opton></select>"); $("#select3").change( function() { var page = $("#select3").val(); if(page == 1){ $("#three").empty(); $("#three").append("<select><option>西岗</opton><option>沙河口</opton></select>"); }else{ if(page == 2){ $("#three").empty(); $("#three").append("<select><option>金州</opton><option>瓦房店</opton></select>"); } } }); }); } }); });
相关文章推荐
- 实际项目开发中需要的格式化标签以及JSTL标签库介绍【1核心标签(用得最多)2 国际化标签(I18N格式化标签) 数据库标签(SQL标签,很少使用) XML标签(几乎不用) JSTL函数(EL函数)】
- 微信开发 使用picker封装省市区三级联动模板
- iOS开发UI篇—使用嵌套模型完成的一个简单汽车图标展示程序
- Git 实际开发中的使用
- 学好spring系列之实际开发初使用
- Android SQLite数据库(事务)的使用,多线程CRUD并发操作(可用于实际开发)
- Android使用android-wheel实现省市县三级联动
- Android 省市县 三级联动(android-wheel的使用)
- Fragment实际开发中的使用
- 使用Ajax+jQuery实现省市区三级联动
- Swift - 省市县三级联动功能的实现(使用UIPickerView选择框)
- ThinkPHP 3.2.2 在 模板中 多重循环嵌套中使用 if 判断标签
- 在Android中使用的省,市,区三级联动,含数据
- javaWeb 使用jsp开发 if 标签
- (二)实际项目使用的开发语言中排序算法实现
- javaWeb 使用jsp开发 if else 标签
- JS封装的三级联动菜单(使用时只需要一行js代码)
- js封装的三级联动菜单(使用时只需要一行js代码)
- JS封装的三级联动菜单(使用时只需要一行js代码)
- 使用listview实现简单的三级地址联动选择器