html - jquery extrack class of child and filter -
i have following html:
<div class="target"> <div class="empty ui-droppable"><div class="item wat ui-draggable" style="position: relative; top: 0px; left: 0px;"><span class="closer"></span> </div></div> <div class="empty ui-droppable"><div class="item ura ui-draggable" style="position: relative; top: 0px; left: 0px;"><span class="closer"></span> </div></div> <div class="empty ui-droppable"><div class="item wat ui-draggable" style="position: relative; top: 0px; left: 0px;"><span class="closer"></span> </div></div> <div class="empty ui-droppable"><div class="item ura ui-draggable" style="position: relative; top: 0px; left: 0px;"><span class="closer"></span> </div></div> <div class="empty ui-droppable"><div class="item ura ui-draggable" style="position: relative; top: 0px; left: 0px;"><span class="closer"></span> </div></div> <div class="empty ui-droppable"><div class="item mox ui-draggable" style="position: relative; top: 0px; left: 0px;"><span class="closer"></span> </div></div> </div>
i extract specific component of each item lives within target.
the component within first child of each item.
the component class wat, mox, or ura.
i have tried many methods can't work. :/
if can tell next appreciated.
btw, if u work needs put in array like: [:ura,:wat,:plu,.......,:ura]
thanks in advance
my fiddle http://jsfiddle.net/ldegc/2/
here solution if keep classes looking in second position have them in fiddle i.e. : 'item classyouwanttoextract'
all go through each item, grab class attr string, split on space, , take 2nd element. hope works you.
var itemarray = []; $('.source .item').each(function(){ var $this = $(this), classes = $this.attr('class').split(' '); itemarray.push(':' + classes[1]); });
Comments
Post a Comment