需要帮助来添加一个班级名称 [英] need help to add one class name

查看:55
本文介绍了需要帮助来添加一个班级名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本,它运行正常.这是用于更少的内容.对于更多内容,这很好,但是当我再次单击时,文本再次变少,但是我想为less按钮添加一个类名.

这是我从中获取脚本的地方.
http://shakenandstirredweb.com/playground/jquery-more-less-text/ [ ^ ]
我只是想越来越多地添加不同的箭头.但总是有一个班级名称.谁能帮我在脚本中添加一个类名.谢谢

 < script    类型  ="  >> 

$(function(){

// 内容块未展开时的高度
 var  Adjustheight =  170 ;
// 更多"链接文本
 var  moreText = " ;
// 较少"链接文本
 var  lessText = " ;

// 将.more-block div设置为指定的高度,并隐藏所有溢出的内容
$(" ).css( height',adjustheight).css(溢出'' 隐藏');

// 该部分已添加到越少"的div底部
$(" ).append( ' < p class ="continued"> […]</p>< a href =#" class ="adjust">< /a>');

$(" ).text(moreText);

$(" ).toggle(function(){
$().parents(" ).find(" ).css('  height'' ' ' // 展开时隐藏[...] 
$().parents(" ).find(" ).css( display'无" );
$().text(lessText);
}, 功能() {
$().parents(" ).find(" ).css('  height',Adjustheight).css(' 溢出'' 隐藏');
$().parents(" ).find(" ).css( display'阻止');
$().text(moreText);
});
});

</ 脚本 >  

解决方案

(function(){ // 内容块未展开时的高度 var Adjustheight = 170 ; // 更多"链接文本 var moreText = " ; // 较少"链接文本 var lessText = " ; // 将.more-block div设置为指定的高度,并隐藏所有溢出的内容

(" ).css (' height',adjustheight).css(' 溢出'' 隐藏'); // 该部分已添加到越少"的div底部


(" ).append(< p class =" continued> […]</p>< a href ="#"class =" adjust"></a>');


Hi, I have the following script, which is working fine. This is for more-less content. For more content, this is good, but when i click again, text becomes less again, but i want to add one class name for the less button.

This is from where i get the script.
http://shakenandstirredweb.com/playground/jquery-more-less-text/[^]
i just want to add different arrows for more and less. but there is always one class name. Can anyone help me in this to add a class name in the script. Thanks

<script type="text/javascript">

$(function(){

// The height of the content block when it's not expanded
var adjustheight = 170;
// The "more" link text
var moreText = "+  More";
// The "less" link text
var lessText = "- 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 class="continued">[…]</p><a href="#" class="adjust"></a>');

$("a.adjust").text(moreText);

$(".adjust").toggle(function() {
		$(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);
});
});

</script>

解决方案

(function(){ // The height of the content block when it's not expanded var adjustheight = 170; // The "more" link text var moreText = "+ More"; // The "less" link text var lessText = "- 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 class="continued">[…]</p><a href="#" class="adjust"></a>');


这篇关于需要帮助来添加一个班级名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆