这是创建数组的可接受方法吗
<ul>
<li class="show" id="all">All Posts</li>
<li class="show" id="user" data-user="7">My Posts</li>
<li class="show" id="follow">Following</li>
</ul>
$(document).ready(function() {
var newarr=[];
$("li").click(function(event) {
var name = event.target.className;
var newclass = 'choice';
$(this).addClass(newclass);
$(this).siblings().removeClass(newclass);
$('li[class~=' + newclass + ']').each(function(index) {
var thisid = $(this).attr('id');
newarr[index] = thisid;
})
$.each(newarr,function(index,value) {
//console.log(index + value);
})
});
});