How to

How to make multiple read more read less buttons in the same one page

How to make multiple read more

<div class="card" data-city="buda">
        BLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it
        <span class="dots">...</span>
        <span class="more" style="display: none;">So make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum..</span>
    <button onclick="readMore('buda')" class="myBtn">Read more</button>
<div class="card" data-city="barca">
        Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
        <span class="dots">...</span>
        <span class="more" style="display: none;"> Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source..</span>
    <button onclick="readMore('barca')" class="myBtn">Read more</button>



function readMore(city) {
    let dots = document.querySelector(`.card[data-city="${city}"] .dots`);
    let moreText = document.querySelector(`.card[data-city="${city}"] .more`); 
    let btnText = document.querySelector(`.card[data-city="${city}"] .myBtn`);

    if ( === "none") { = "inline";
        btnText.textContent = "Read more"; = "none";
    } else { = "none";
        btnText.textContent = "Read less"; = "inline";


Show More

Related Articles

Leave a Reply

Back to top button

Adblock Detected

We Noticed You are using Ad blocker :( We Work Really Hard and Spend Huge Time to test and verify these files for you. Please Support us By Disabling Ad blocker for this Domain. We dont show any popups or Poor Ads. Because we hate them too. If you cannot disable Ad blocker for our site. We can understand, Dont Worry! Your Download will start always regardless of Ad Blocker. Consider sending us small donation. Because we want to keep this site free as long as possible.