这是我当前的 html 结构。
<div id="eventContainer">
<div id="10_10_am" class="eventbytimeContainer"> some data... </div>
<div id="08_30_pm" class="eventbytimeContainer"> some data... </div>
<div id="09_00_am" class="eventbytimeContainer"> some data... </div>
<div id="04_00_pm" class="eventbytimeContainer"> some data... </div>
<div id="10_30_am" class="eventbytimeContainer"> some data... </div>
<div id="09_30_pm" class="eventbytimeContainer"> some data... </div>
</div>
我想根据 div id 对其进行排序,这些 id 只不过是格式化的时间,比如10_10_am
mean 10:10 am
。我想要的结构是:
<div id="eventContainer">
<div id="09_00_am" class="eventbytimeContainer"> some data... </div>
<div id="10_10_am" class="eventbytimeContainer"> some data... </div>
<div id="10_30_am" class="eventbytimeContainer"> some data... </div>
<div id="04_00_pm" class="eventbytimeContainer"> some data... </div>
<div id="08_30_pm" class="eventbytimeContainer"> some data... </div>
<div id="09_30_pm" class="eventbytimeContainer"> some data... </div>
</div>
如何计算这些 id 并进行相应排序?