Hi I am using Masonry with Laravel and I am basically loading my blogs into a masonry layout. I have an abstract which I output as well as all the content, the content is hidden by default by CSS. I have a read more button once clicked, adds a class to that div which expands the masonry block and hides the abstract and shows the full content.
However when I click read more on another div the div.fullstory is shown, I want to hide this but I'm not sure how to I've tried to use the jQuery previous method but this doesn't seem to be working out for me.
A simple version of my code is below or please view my JSFIDDLE
Any help much appreciated.
HTML:
<div id="masonary-blogs">
<div class="one-third column">
<h3>title</h3>
<div class="abstract">
<p>abstract</p>
</div>
<div class="fullstory">
<p>fullstory</p>
</div>
<div class="button">
<a href="#" id="read-more">Read more</a>
</div>
</div>
<div class="one-third column">
<h3>title</h3>
<div class="abstract">
<p>abstract</p>
</div>
<div class="fullstory">
<p>fullstory</p>
</div>
<div class="button">
<a href="#" id="read-more">Read more</a>
</div>
</div>
<div class="one-third column">
<h3>title</h3>
<div class="abstract">
<p>abstract</p>
</div>
<div class="fullstory">
<p>fullstory</p>
</div>
<div class="button">
<a href="#" id="read-more">Read more</a>
</div>
</div>
</div>
CSS:
.one-third {
width:23%;
background:#dedede;
min-height:100px;
}
.column {
display:inline-block;
margin-left:5px;
margin-right:5px;
}
.fullstory {
display:none;
}
.gigante {
width:100%;
}
.hide {
display:none;
}
.show {
display:block;
}
JQUERY:
$('#masonary-blogs').on('click', 'a', function(e){
var blogItem = $(this).parents('.one-third'),
container = $('#masonary-blogs');
e.preventDefault();
console.log('Blog link click');
$('.gigante').removeClass('gigante');
$(e.target).parents('.one-third').addClass('gigante');
$(e.target).prev('div.abstract').show();
$(e.target).prev('div.content').hide();
});