如何在忽略第一个元素的同时用jQuery解析JSON?

时间:2016-06-28 00:29:54

标签: javascript jquery json

我有以这种格式的JSON数据:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<button>Open Modal</button>

<form>
  Value of checkbox myCB:<br>
  <input type="text" name="inFormCB" />
</form>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <p>Some text in the modal.</p>
        <input id="myCB" type="checkbox" /> Got It
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

如何忽略&#39;状态&#39;部分数据并使用jQuery构建基于open_slots的列表?

1 个答案:

答案 0 :(得分:3)

p

现在你可以只打开空位:

var json = JSON.parse(input);
var json_keep = json.open_slots;