Seeking to duplicate an object, I am trying to figure out how to retrieve class CSS attributes from Mootools.
css:
.card {
width: 109px;
height: 145px;
}
html:
<div id="cards">
<div class="card" id="c0">
<div class="face front"></div>
<div class="face back"></div>
</div>
</div>
js:
window.addEvent('domready', function(){
Duplicacartes();
});
function Duplicacartes(){
var uiCards= document.getElementById('cards');
for(var i=1;i<521;i++)
{
var clone = $('c0').clone();
clone.set('id', 'c'+i);
clone.setStyle('left', (clone.getStyle('width') + 20) * (i % 40));
clone.setStyle('top', (clone.getStyle('height') + 20) * Math.floor(i / 40));
clone.inject('cards','bottom');
}
However, I am not getting the desired outcome:
The function clone.getStyle() only retrieves the 'element' attributes, not the class CSS attributes. I have tried numerous methods without success.
$('c'+i).getStyle('width');
$('c'+i).style.width;
...
Can anyone advise on the correct approach? Thank you.