i have this on click function which is meant to adjust the conatiner height, bit like a toggle but does not seem to work:
JSFIDDLE: http://jsfiddle.net/0tb115ez/1/
JS:
$(function() {
// The height of the content block when it's not expanded
var adjustheight = 240;
// The "more" link text
var moreText = "Click to read more...";
// The "less" link text
var lessText = "Click to read less...";
// Sets the .more-block div to the specified height and hides any content that overflows
$(".more-less .more-block").css('height', adjustheight).css('overflow', 'hidden');
// The section added to the bottom of the "more-less" div
$(".more-less").append('<p><a href="#" class="adjust"></a></p>');
$("a.adjust").text(moreText);
$(".adjust").on("click",function(e) {
$(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible');
// Hide the [...] when expanded
$(this).parents("div:first").find("p.continued").css('display', 'none');
$(this).text(lessText);
}, function() {
$(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden');
$(this).parents("div:first").find("p.continued").css('display', 'block');
$(this).text(moreText);
});
});
.click()only receives one callback, not too. You'll need to handle the toggling in the click function on your own. Also, since you're using an anchor tag, you'll probably want to adde.preventDefault();as your first statement in the callback to keep the link from refreshing the page..toggle(function, function), I feel the need to also point out that was deprecated in jQuery 1.8 and removed in 1.9.