我有这段代码:
function ready() {
$("#my_form").on("submit", function (e) {
for (var j in someItems) {
var element = $(someItems[j]);
$("<input>").attr({type: "hidden", name: element.attr("name"), value: element.val()}).appendTo($(this));
}
for (var i = 0; i < someItems2.length; i++) {
// "element" is visible here ??????
$("<input>").attr({type: "hidden", name: element.attr("name"), value: element.val()}).appendTo($(this));
}
});
});
jQuery(document).ready(ready);
jQuery(document).on("page:load", ready);
为什么变量element
在第二个循环中可见?