我有这样的结构:
<ul id="list">
<li data-day="monday">BlaBla</li>
<li data-day="friday">BlaBla</li>
<li data-day="tuesday">BlaBla</li>
</ul>
我想阅读该数据属性,然后检查代表星期几的NUMBER,例如:
$('#list').each(function(){
var day = $($this).data('day'); //day = monday
//MAKE SOMETHING BETTER THAN A BUNCH OF 'IF'S CONDICIONAL
//TO COMPARE THE DAY AND RELATE IT TO THE NUMBER OF THE WEEK.
//Now using `momentjs` I need to relate monday with the number day of the week. Knowing that monday is equivalent of 1.
if(day = "monday"){ var numDay = 1}
else if(day = "sunday"){ var numDay = 2}
});