这是代码:
// Each ul that holds the collection of our entities
var lists = ['ul.emails', 'ul.phoneNumbers'];
// Setup the "add" link
var $addLink = $('<a href="#" class="margin-left btn btn-mini add"><i class="icon-plus"></i>label</a>');
var $newLinkLi = $('<li></li>').append($addLink);
$(document).ready(function() {
// Add link to each list
$.each(lists, function(index, list) {
$(list).append($newLinkLi);
});
});
但是,只有最后一个ul
获得链接。但是,如果我这样做
$.each(lists, function(index, list) {
$(list).append('test');
});
有用。是什么赋予了?是通过引用传递的吗?