87,922
社区成员
发帖
与我相关
我的任务
分享
<select id="DDL_Country"></select>
(function() {
var a = $("#DDL_Country"),
b = $("#DDL_Province"),
c = $("#DDL_City"),
data = { 1: { n: "中国" }, 2: { n: "美国"} };
var methods = {
init: function() {
alert('这里测试弹出');
var aaa = '';
$.each(data, function(i, item) {
aaa += "<option>" + item.n + "</option>";
});
$("#DDL_Country").html(aaa);
alert('这里都弹出了,中间的还没执行?');
}
};
//methods.init(); //这样调用init方法,两个alert都会弹出,但中间的代码不起作用,求解释!
$(function() { methods.init(); });//这样调用中间代码就起作用了。
})();