Click here to Skip to main content
16,021,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this code below it's a tab consisting of objects from multidimensional array the problem is that i'm trying to add a show more button on every one of my paragraph but i cant seem to find anything online that works for me. Any help would be greatly appreciated!

What I have tried:

Here is my Fiddle[^]
Posted
Updated 20-Jun-18 23:02pm

1 solution

There's two things wrong with your code:

- $content is not correctly referenced
- You're not linking jquery-ui.js, which is required for switchClass

Try this: JSFiddle[^]
 
Share this answer
 
Comments
Member 13863747 21-Jun-18 5:11am    
That worked perfectly but may i ask because i'm getting this example of button from stack so im not sure how this guy set the amount of word he want to show
[no name] 21-Jun-18 5:13am    
The number of words is not set directly. In the collapsed state, p has class hideContent, which has height 2em (= two lines). In the expanded case, p has class showContent which has height auto (= as high as needed to fit the text).
Member 13863747 21-Jun-18 5:17am    
oh ok that make sense one last thing im not too sure why i cant remove the quotation marks from the buttons
[no name] 21-Jun-18 5:19am    
Change this line:
button.innerHTML = ` "<a href="#">Show more</a>"`;

To:
button.innerHTML = ` <a href="#">Show more</a>`;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900