html部分
<div _start="9:00" _end="10:00" class="s">
<div class="sTitle">9:00 - 10:00</div>
</div>
<div _start="11:00" _end="12:00" class="s">
<div class="sTitle">11:00 - 12:00</div>
</div>
<div _start="13:00" _end="14:00" class="s">
<div class="sTitle">13:00 - 14:00</div>
</div>
JS部分
var s = $(".s");
var arr= [];
for(var c=0; c<s.length; c++){
var json = {
'start': s.eq(c).attr("_start"),
'end': s.eq(c).attr("_end")
};
arr.push(json);
}
结果:
[
{start: '9:00', end: '10:00'},
{start: '11:00', end: '12:00'},
……
]