<div id="item1" class="dragbox">icerik 1</div>
<div id="item2" class="dragbox">icerik 2</div> </div>
<div class="column" id="column2">
<div id="item3" class="dragbox">icerik 3</div>
<div id="item4" class="dragbox">icerik 4</div> </div>
<div class="column" id="column3">
<div id="item5" class="dragbox">icerik 5</div>
<div id="item6" class="dragbox">icerik 6</div> </div>
<button id='show'>get each elements</button>
$("#show").click(function() { var n = getDivElements(); alert(n); }); function getDivElements() { var degisken=""; $('.column').each(function() { degisken+=this.id+"="; var j=0; var eachsize=$('#'+this.id).children().size(); $('#'+this.id).children().each(function() { degisken+=this.id; j++; (j <= (eachsize-1)) ? degisken+="-" : degisken; });degisken+=","; }); return degisken=degisken.substring(0, degisken.length - 1); }
Sonuç: column1=item1-item2,column2=item3-item4,column3=item5-item6
Bu siteden testini yapabilirsiniz. http://jsfiddle.net/
Teşekkürler.
YanıtlaSil