Remove item from JSON object Array using JavaScript and jQuery

Last Reply one year ago By dharmendr

Posted one year ago

Hello All,

I have model collection in JQUERY thiz.tprListSearchesAndViews.searchParameters[0].parameters.

This has 16 parameters list, as shown in the Image 1, I need to remove 2 items in the the parameters collection.

Could you please help me, how I can do this. I am not getting any idea how I can approach on this using Jquery.

Image1 :

Image2 :

Posted one year ago Modified on one year ago

Hi bhadriau,

Use jQuery splice Method.

Refer below example.


<script type="text/javascript">
    function RemoveItems(index) {
        var customers = [{ CustomerId: 1, Name: "John Hammond", Country: "United States" },
                        { CustomerId: 2, Name: "Mudassar Khan", Country: "India" },
                        { CustomerId: 3, Name: "Suzanne Mathews", Country: "France" },
                        { CustomerId: 4, Name: "Robert Schidner", Country: "Russia"}];
        // Remove item from specified index.
        customers.splice(index, 1);
<input type="button" value="Submit" onclick="RemoveItems(1);" />