/* 可添加样式也可不添加 依照个人需求自行添加样式 */
仅仅是初始代码,
可能有些许bug,
望谅解,有详细注释,
来自一个正在努力成长的校园新人
//给省添加改变事件
$(".prove").change(function() {
var $index1 = $(this).find(":selected").index();
window.$index1 = $index1; //清空城市列表以便再次添加
$(".city").empty();
$(".county").empty();
$("<option></option>").text("请选择城市").appendto(".county") citys[$index1].foreach(addcity);
big[$index1][0].foreach(addcounty);
})
回复
改进了一下,解决了选择省之后无法自动选到县的问题
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>document</title>
</head>
<style>
* {margin: 0;padding: 0; }select {width: 150px;height: 30px; }
</style>
<body> <select name=""></select> <select name=""></select> <select name="" value="122"></select> </body>
</html>
回复