i have the current .each in my javascript
var divs = array();
$('.div-item').each(function(){
var id = $(this).attr('id');
divs.push(id);
});
How would开发者_Python百科 I delete an id from the array programmatically?
function deleteId(divArray, id) {
var idx = $.inArray(id, divArray);
if(idx != -1)
divArray.splice(idx, 1);
}
EDITED: to use $.inArray: some versions of IE don't support the indexOf
method on arrays.
var list = [4,5,6];
list.splice(1, 1); // Remove one element, returns the removed ones.
list now equals [4,6]
精彩评论