1. <input type="text" id="app">
    2. <script>
    3. var arr = [
    4. {name:"李四",id:"1001"},
    5. {name:"王四",id:"1002"},
    6. {name:"张四",id:"1003"},
    7. {name:"赵四",id:"1004"}
    8. ]
    9. /*
    10. 1.要获取数组中的值
    11. 2.根据id值 获取数组中对应项的下标
    12. 3.删除对应的项
    13. */
    14. var app = document.getElementById("app");
    15. app.onkeydown = function(event){
    16. if(event.keyCode==13){
    17. var id =Number(this.value);
    18. var index =arr.findIndex(item=>{
    19. return item.id == id;
    20. })
    21. arr.splice(index,1);
    22. console.log(arr)
    23. }
    24. }
    25. </script>