我有这个上这是为了调整conatiner高度,有点像一个切换,但似乎并没有工作,点击功能点击功能:在不工作
的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);
});
});
['。点击()'](HTTP://api.jquery。 com/click /)只接收一个回调,不是。您需要自行处理点击功能中的切换。此外,由于您使用的是锚标记,你可能会想加上'e.preventDefault();'作为回调的第一条语句来保持链路从刷新页面。 – War10ck 2014-09-18 15:49:38
旁注:如果你指的是语法切换处理程序:['.toggle(函数,函数)'](http://api.jquery.com/toggle-event/),我觉得有必要也点out在jQuery 1.8中被弃用,并在1.9中被删除。 – Stryner 2014-09-18 15:52:57
即时通讯新本所以真的不知道该怎么办内德拨动但生病尝试感谢 – 2014-09-18 15:53:11