<select name="region[]" class="region" >
<option value="">--请选择--</option>
<?php foreach ($region_data as $k => $val): ?>
<option value="<?php echo $val->region_id?>"><?php echo $val->region_name?></option>
<?php endforeach ?>
</select>
<script>
$(function(){
$(document).on('change','.region',function(){
var region_id=$(this).val();
var _this=$(this);
if (region_id<0) {
_this.nextAll().remove();
return false;
}
$.post('publish_position',{'region_id':region_id},function(msg){
console.log(msg);
if (msg.length>0) {
str='<select name="region[]" class="region">';
str+='<option value="-1">--请选择--</option>';
$(msg).each(function(k,v){
str+='<option value='+v.region_id+'>'+v.region_name+'</option>';
})
str+='</select>'
_this.nextAll().remove();
_this.after(str);
}
},"json")
})
})
</script>
jquery 无限极联动【地区】
最新推荐文章于 2019-01-25 10:41:28 发布