下面的代碼:
// 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');
});
它的工作原理。是什麼賦予了?是通過引用傳遞的東西嗎?