I want to go through each of the .clipped-box elements and pass them through the following function:
(genClips = function() {
// For easy use
$t = $('.clipped-box');
// Like I said, we're using 5!
var amount = 5;
// Get the width of each clipped rectangle.
var width = $t.width() / amount;
var height = $t.height() / amount;
// The total is the square of the amount
var totalSquares = Math.pow(amount, 2);
// The HTML of the content
var html = $t.find('.content').html();
var y = 0;
for(var z = 0; z <= (amount*width); z = z+width) {
$('<div class="clipped" style="clip: rect('+y+'px, '+(z+width)+'px, '+(y+height)+'px, '+z+'px)">'+html+'</div>').appendTo($t);
if(z === (amount*width)-width) {
y = y + height;
z = -width;
}
if(y === (amount*height)) {
z = 9999999;
}
}
})();
I have several .clipped-box elements in the HTML as follows:
<div class="clipped-box piece1">
<div class="content">
<img src="img/piece1.png">
</div>
</div>
<div class="clipped-box piece2">
<div class="content">
<img src="img/piece2.png">
</div>
</div>
How can I adapt it to this?