Delete an element inside a JSON array by value with jQuery

后端 未结 4 555
夕颜
夕颜 2020-12-19 08:25

Part of my json Array

var videos = $j.parseJSON(\'
  [
    { \"privacy\":\"public\",
      \"id\":\"1169341693\" },

    { \"privacy\":\"private\",
      \"i         


        
4条回答
  •  失恋的感觉
    2020-12-19 08:38

    You can use grep :

    videos = $.grep(videos, function(e) { return e.id!='803641223' });
    

    In vanilla JavaScript you could have used the similar filter function but it's not supported by IE8.

    Please note that videos is a JavaScript array, it's not a JSON array, even if it was made by parsing a JSON string.

提交回复
热议问题