Here is the jQuery code for showing readmore and read less with sliding effect. You have to just add the jQuery.js file and the below javascript code.
Read More
var sliderHeight = "40";
$(document).ready(function(){
$('.slider').each(function () {
var current = $(this);
current.attr("box_h", current.height());
if(current.height() <= sliderHeight) $('#readmore_cnt').hide(); }); $(".slider").css("height", sliderHeight+ "px"); $(".slider_menu").click(function() { openSlider() }) }); function openSlider() { var open_height = $(".slider").attr("box_h") + "px"; $(".slider").animate({"height": open_height}, {duration: "slow" }); $(".slider_menu").html('');
$(".slider_menu").removeClass('view-more');
$(".slider_menu").addClass('view-less');
$(".slider_menu").unbind("click");
$(".slider_menu").click(function() { closeSlider() });
}
function closeSlider()
{
$(".slider").animate({"height": sliderHeight+ "px"}, {duration: "slow" });
$(".slider_menu").html('');
$(".slider_menu").removeClass('view-less');
$(".slider_menu").addClass('view-more');
$(".slider_menu").unbind("click");
$(".slider_menu").click(function() { openSlider() });
}
No comments:
Post a Comment