<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src="../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function () {
var $select = $("#slt");
var id = new Array(1, 2, 3);
var val = new Array("北京", "天津", "上海");
for (var i = 0; i < id.length; i++) {
$select.append("<option value=" + id[i] + ">" + val[i] + "</option>");
}
//通过下拉列表中option的value值来进行默认选中
//$select.find("option[value=3]").attr("selected",true);
//通过下拉列表中包含的文本内容来进行默认选中
$select.find("option:contains('上海')").attr("selected", true);
})
</script>
</head>
<body>
<select id="slt">
<option value="0"></option>
</select>
</body>
</html>