How to remove the max-height setting from a single div element via class attribute upon click?
I have several rows of text, each row is enclosed within a div. For example;
<div class="promotext">Blah Blah Blah</div>
<div class="promotext">Blah Blah Blah</div>
<div class="promotext">Blah Blah Blah</div>
In the css stylesheet I have the setting
.promotext {max-height:3.7em; overflow:hidden;}
This ensures that if 'Blah blah blah' gets too long, after 3 lines, the text overflow is hidden. However, I want to enable the functionality that if a user clicks on the 'Blah blah' text, the max-height property is removed or nullified so that the full text becomes visible - however, only the div that was clicked should expand.
So setting a new style on .promotext wont cut it because all the text rows will expand, because we only want the clicked upon div to expand. The text rows are generated dynamically, sometimes there is 1-3 rows, sometimes there is upto 50 text rows. I cannot assign a unique ID to each text row as it is a template which repeats itself.
Any help in creating an expanding div solution would be much appreciated. Thanks.
Start Free Trial