I have an array of items like:
var items = [id: "animal", type: "cat", cute: "yes"]
And I’m trying to remove any items that match the ID given. In this case; animal
I’m stuck! I can get it to work easily by having a more simpler array but this is not what I need… I also need to remove the item by value as I don’t want the hassle of referring to items by their index.
Is there a jQuery method I could use where I don’t need to iterate through the items array, rather specify a selector?
Here is my jsFiddle: http://jsfiddle.net/zafrX/
I’m not sure how much of a hassle it is to refer to array items by index. The standard way to remove array items is with the splice method
And of course you can generalize this into a helper function so you don’t have to duplicate this everywhere.
EDIT
I just noticed this incorrect syntax:
Did you want something like this:
That would change the removal code to this: