中定义的某个点开始。我有一个包含一个div的所有文字,如:Collapsable div,但是从变量
<div class="text-container">
<p>
Though we welcome the idea of a smaller connector, we're miffed that Apple couldn't just adopt the semi-industry standard of Micro-USB. That would make things easier for smartphone users across the globe. Yet, even so, the smaller connector may be a smart move for the future. The 30-pin connector has been around since 2003, long before the iPhone even existed: frankly, it's a dust magnet. A smaller connector helps shave extra space to achieve a smaller phone with perhaps a bigger battery. The new connector cable will mainly be used for syncing and charging by most people who own an Apple TV or Bluetooth/AirPlay accessories.
</p>
</div>
而且我想创造这样的事情:
<div class="text-container">
<p>
Though we welcome the idea of a smaller connector...<a href="some-javascript-to-show-more">[show more]</a>
</p>
</div>
我想我应该得到的div的所有内容,然后找到首先例如50个字符并放置一个链接,并将所有其他文本放入一些将被隐藏的div中,并在点击该链接后显示其他内容。
它应该是类似于切换的,如果它展开,则将文本从[show more]更改为[show less],反之亦然。
任何建议如何使用普通的javascript和jquery本身并且没有其他jQuery插件来实现这一点?
你已经回答了你的问题:“我想我应该得到的div的所有内容,然后找到的第一个如50个字符,并把有联系和所有其他文本放在一些将被隐藏的div中,点击链接后,其他的东西就会显示出来。“ – ankur
是的,但我不是很好的JavaScript和jQuery,我可以自己解决它。我需要一点点帮助,如何解决这个问题。我相信未来也会有其他人从中受益。 – Derfder