-1
我有以下的JSON如何使用JavaScript或Jquery向上或向下移動數組項目?
{ "EmployeeLists": [
{
"ID": 1,
"NAME": "Anand",
"Salary": 90000
},
{
"ID": 2,
"NAME": "Anbu",
"Salary": 80000
},
{
"ID": 3,
"NAME": "Bala",
"Salary": 85000
} ]}
我想數組項2移動到向上或向下。預期產出如下。
{ "EmployeeLists": [
{
"ID": 2,
"NAME": "Anbu",
"Salary": 80000
},
{
"ID": 1,
"NAME": "Anand",
"Salary": 90000
},
{
"ID": 3,
"NAME": "Bala",
"Salary": 85000
} ]}
您可以通過交換功能做到這一點。 http://stackoverflow.com/questions/4011629/swapping-two-items-in-a-javascript-array – jadok