在javascript中添加数组对象和删除数组对象?

在javascript中添加数组对象和删除数组对象?,javascript,jquery,arrays,Javascript,Jquery,Arrays,我想删除数组中的一个对象,同时向数组中添加新对象。有谁能解决这个问题吗 Default.aspx: <div data-role="content"> <div> <div id="addNewDocumentRelationShip" data-inline="true" style="float:left" data-role="button" class="ui-btn-left" rel="external" data

我想删除数组中的一个对象,同时向数组中添加新对象。有谁能解决这个问题吗

Default.aspx:

<div data-role="content">
        <div>
            <div id="addNewDocumentRelationShip" data-inline="true" style="float:left" data-role="button" class="ui-btn-left" rel="external" data-theme="b">Add New Item</div>
            <div id="removeDocumentRelationShip" data-inline="true" style="float:right" data-role="button" class="ui-btn-right" rel="external" data-theme="b">Remove</div>
        </div>
        <div id="lookupItemsDisplayList">            
        </div>
</div>
edit.js:

var lookupDiv = document.getElementById('lookupItemsDisplayList');

$(lookupDiv).html("");

// create new div that will work as a container
var newlookupDiv = $('<div></div>').attr('data-role', 'fieldcontain'); 

var fieldset = $('<fieldset></fieldset>').attr('data-role', 'controlgroup');

var checkBox = constants.EMPTY_STRING;

for (var item in lookupsArray) {
            checkBox = checkBox + "<input type='checkbox' data-theme='b' id='" + lookupsArray[item].Item + "' name='check' value='" + lookupsArray[item].DisplayValue + "'><label for='" + lookupsArray[item].Item + "' data-iconpos='right'>" + lookupsArray[item].DisplayValue + "</label>";
        }

   fieldset.html(checkBox);
   newlookupDiv.html(fieldset);
   $(lookupDiv).html(newlookupDiv);
   $(lookupDiv).trigger('create');
var lookupDiv=document.getElementById('lookupItemsDisplayList');
$(lookupDiv.html(“”);
//创建将用作容器的新div
var newlookupDiv=$('').attr('data-role','fieldcontain');
var fieldset=$('').attr('data-role','controlgroup');
var checkBox=constants.EMPTY\u字符串;
for(lookupsArray中的变量项){
复选框=复选框+“”+查找数组[项]。显示值+“”;
}
html(复选框);
html(字段集);
$(lookupDiv).html(newlookupDiv);
$(lookupDiv.trigger('create');

var constants.constLookupArray
Constant.js文件包含变量(var constLookupArray=[];作为对象)。在Edit.js文件中,我访问该变量,如constant.constLookupArray={//assign object}
var lookupDiv = document.getElementById('lookupItemsDisplayList');

$(lookupDiv).html("");

// create new div that will work as a container
var newlookupDiv = $('<div></div>').attr('data-role', 'fieldcontain'); 

var fieldset = $('<fieldset></fieldset>').attr('data-role', 'controlgroup');

var checkBox = constants.EMPTY_STRING;

for (var item in lookupsArray) {
            checkBox = checkBox + "<input type='checkbox' data-theme='b' id='" + lookupsArray[item].Item + "' name='check' value='" + lookupsArray[item].DisplayValue + "'><label for='" + lookupsArray[item].Item + "' data-iconpos='right'>" + lookupsArray[item].DisplayValue + "</label>";
        }

   fieldset.html(checkBox);
   newlookupDiv.html(fieldset);
   $(lookupDiv).html(newlookupDiv);
   $(lookupDiv).trigger('create');