简体   繁体   中英

show and hide doesn't the opposite of it

我有显示和隐藏功能,我想显示300行,当您按更多时,它应该显示其余文本,但并非相反,这意味着它显示所有文本,并且在您单击更多时显示显示较少。

You need to assign "showcontent" class an initial style of "display:none;", then every thing should work as expected.

var html = firstcontent + '<p class="showcontent" style="display:none;">' + secondcontent + '</p><a href="" class="morebtn">' + show_more + '</a></p>';

Working demo: https://jsfiddle.net/48r998f6/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM