请允许我说,我们有以下的:
<ul id="portfolio-list" class="clearfix span-24">
<li class="2012#foo bar car#cat_1">item 1 <br /></li>
<li class="2011#car foo fly#cat1">item2 <br /></li>
<li class="2009#car fly swat_car#cat_2">item3<br /></li>
<li class="2012#bar show car#cat_3">item 4<br /></li>
</ul>
and I want to create a map the classes each item to do the following:
- I m trying to split the code into three parts
- output each piece and
- add them to their own array of values.
采用以下代码,它只能从最后一份清单中收回价值。
我怎样把它放在名单上的项目之上,并增加每个项目的价值。
守则如下:
jQuery(document).ready(function($) {
var splitList = $("#portfolio-list li").map(function() {
inStringy = $(this).attr("class").split( # );
list = $(this).attr( class );
list = list.split("#").join(" ");
$(this).removeClass();
var that = $(this);
$(that).addClass(list);
return inStringy;
});
cla = [];
yr = inStringy[0];
classListin[classListin.length] = cla + "";
categoryListin[categoryListin.length] = cat + " ";
cla = inStringy[1];
cla = cla.split(" ");
cat = inStringy[2];
yearListin = [];
classListin = [];
categoryListin = [];
yearListin[yearListin.length] = yr + "";
classListin[classListin.length] = cla + "";
categoryListin[categoryListin.length] = cat + " ";
});
任何帮助都值得赞赏!