基本上我有这个 JS 脚本,当单击它时,它会显示更多文本。问题是,它所在的 div 与所有文本都在其中时一样大。我希望 div 仅与文本预览一样大,然后当您单击 + 按钮时,div 会扩展为与所有文本一样大。
以下是未展开时的样子:http: //puu.sh/FZj6 当它展开时:http: //puu.sh/FZjD
如您所见,div 大小始终保持不变。
JS
function hx(elmnt){document.getElementById(elmnt).style.visibility="hidden";}
function sx(elmnt){document.getElementById(elmnt).style.visibility="visible";}
HTML
This is the text that is automatically there. When you click the + to the left, the rest of the text appears. (<a onClick="sx('more')" style="cursor:pointer;" title="Show more">+</a>)
<div id="more" style="visibility:hidden;">
<p>(<a onClick="hx('more')" style="cursor:pointer;" title="Show less">-</a>)<br /><br>
This is the text that appears when the + is clicked. The - above removes this text. When the minus is clicked, the div should restore to original size.
任何帮助,将不胜感激!谢谢。