需要帮助展开展开文本的折叠部分 [英] Need help with expand collapse part of displaying text

查看:49
本文介绍了需要帮助展开展开文本的折叠部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是javascript和ajax的新手。我想创建一个文本并展开并折叠它的一部分。类似于youtube中的内容。我有这个代码。


[HTML]<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0过渡// EN">

< html>

< head>

< title>< / title>

< script type =" text / javascript">

函数showBlock(blockId)

{

document.getElementById(blockId).style.display =" block";

}

function hideBlock(blockId)

{

document.getElementById(blockId).style.display =" none" ;;

}

< / script>

< / head>

< body>

显示隐藏文字

< a href =" ;的JavaScript的 的:执行showblock( '' 块1 '')">展开< / a>

< div id =" block1" style =" display:none">

如果点击

< a href =" javascript ,可以再次隐藏此文字:hideBlock(''block1'')"> collaps< / a> ;.

< / div>

< / body>

< / html>

[/ HTML]


我有一个问题我无法摆脱扩展文本扩展时。有人可以帮助我摆脱文本被完全扩展时的扩展,所以我只会留下崩溃。 。


谢谢

Ronen

Hi,

I am new to the javascript and the ajax. I want to create a text and expand and collapsonly part of it . Something similar to what is done in youtube., I have this code.


[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script type="text/javascript">
function showBlock(blockId)
{
document.getElementById(blockId).style.display = "block";
}
function hideBlock(blockId)
{
document.getElementById(blockId).style.display = "none";
}
</script>
</head>
<body>
Show hidden text
<a href="javascript:showBlock(''block1'')"> expand</a>
<div id="block1" style="display: none">
This text can be hidden again if you click
<a href="javascript:hideBlock(''block1'')">collaps</a>.
</div>
</body>
</html>
[/HTML]

I have one problem I can not get rid from the "expand" when the text is expanded. Can some one help me to rid of the "expand when the text is fully exapanded so I will be left only with "collaps" .

Thanks
Ronen

推荐答案

欢迎来到TSDN!


为什么你要显示相同的东西,但切断m如果整个文本已经显示?


无论如何,你可以这样做:

[HTML]< span id =" toHide">折叠时隐藏的文字< / span>文本的其余部分< a href ="#" onclick =" expandcollapse(this)"> less< / a> [/ HTML]和javascript
Welcome to TSDN!

Why do you want to display the same thing, but cut off on the "m" if the whole text is already displayed?

Anyway, you could do something like:
[HTML]<span id="toHide">Text that will be hidden on collapse</span>The rest of the text <a href="#" onclick="expandcollapse(this)">less</a>[/HTML] and the javascript:
展开 | 选择 | Wrap | 行号



欢迎来到TSDN!


为什么你要展示同样的东西,但要切断在m上如果整个文本已经显示?


无论如何,你可以这样做:

[HTML]< span id =" toHide">折叠时隐藏的文字< / span>文本的其余部分< a href ="#" onclick =" expandcollapse(this)"> less< / a> [/ HTML]和javascript
展开 | 选择 | Wrap | 行号


哦,您必须在我发布后编辑您的帖子。


请记住在发布代码时使用代码标签:

[CODE = javascript]

像这样的JavaScript代码。

[/ code]
Oh, you must have edited your post after I posted.

Please remember to use code tags when posting code:

[CODE=javascript]
Like this for JavaScript code.
[/code]


这篇关于需要帮助展开展开文本的折叠部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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