I have a simple masonry layout. And need to change elements size and position on click.
Here is a jsfiddle: http://jsfiddle.net/664cV/12/ and the code:
JS
$(function(){
$('#container').isotope({
itemSelector: '.box'
});
$('.box').click(function(){
$('.box').width(100).height(100);
$(this).width(300).height(300);
$('#container').isotope('reLayout');
});
});
CSS
#container {
width: 400px;
}
.box {
font-size: 28px;
width: 100px;
height: 100px;
}
/* omitted color classes */
HTML
<div id="container">
<div class="box red">1</div>
<div class="box blue">2</div>
<div class="box green">3</div>
<div class="box yellow">4</div>
<div class="box black">5</div>
</div>
The problem is that it isn't working correctly for element number 1 and number 3 (see images)
Element 1 clicked (solved: see answer)
Element 3 clicked
What am I doing wrong?