简体   繁体   English

jQuery仅在div的表格单元中读取更多链接

[英]jquery read more link in a div's table cell only

so, this is the situation. 就是这种情况。 I've got a table in a div, and this table contains a php recalling a content from MySQL. 我在div中有一个表,该表包含一个PHP,用于从MySQL调用内容。 The fields are like "name", "surname" but also "comment" or "description", that can be quite long, So I'd like to cut them a certain point (like 150 letters) and than add a "read more". 这些字段就像“名称”,“姓氏”,但也可以是“注释”或“描述”,可能会很长,所以我想将它们切到某个点(例如150个字母),而不是添加“阅读更多” ”。 I've tried jquery shorten codes but those only work for the entire div, not for single cells. 我尝试了jquery缩短代码,但它们仅适用于整个div,不适用于单个单元格。

Can you guys help me? 你们能帮我吗? Thanks a lot! 非常感谢!

M 中号

Try to put 2 things in your long cells (comment & description) : 尝试在长单元格中放入两件事(注释和描述):

  1. The shortened text you have by using the substr() method 通过使用substr()方法获得的缩短文本
  2. The full text 全文

Only show the 1. and on click on your "Read more...", hide the 1. and show the 2. 仅显示1.,然后单击“阅读更多...”,隐藏1.,然后显示2。

I wanted to precise my anwser by some HTML / JS code but I'll give you all you give us to get your answer. 我想通过一些HTML / JS代码来精简我的答案,但是我会给你你给我们的一切,以得到答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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