"See more" button | Experience Community
Skip to main content
Solved

"See more" button

  • Sep 27, 2023 4:19 PM UTC
  • 5 replies
  • 491 views

Forum|alt.badge.img+1

How can I include a "see more" button in my question, where the respondent can click on the button and display more details about the question?

Best answer by Nam Nguyen

@Vsolbiati Add this html to your question source

<style type="text/css">#hidden-paragraph {
display: none;
}
</style>
<p>The short part of the question <span id="hidden-paragraph">The hidden part that will be revealed when you click see more button....................ble bla bla</span></p>
<button id="see-more-button">See more...</button>

Add this to Javascript to activate the button

Qualtrics.SurveyEngine.addOnReady(function() {
document.getElementById("see-more-button").addEventListener("click", function() {
var hiddenParagraph = document.getElementById("hidden-paragraph");
if (hiddenParagraph.style.display === "none") {
hiddenParagraph.style.display = "inline";
this.textContent = "See less...";
} else {
hiddenParagraph.style.display = "none";
this.textContent = "See more...";
}
});
});

Hope this helps

View original

5 replies

Forum|alt.badge.img+14
  • Level 5 ●●●●●
  • Sep 27, 2023 4:29 PM UTC

There’s instructions here for that: 

 


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • Answer
  • Sep 27, 2023 4:36 PM UTC

@Vsolbiati Add this html to your question source

<style type="text/css">#hidden-paragraph {
display: none;
}
</style>
<p>The short part of the question <span id="hidden-paragraph">The hidden part that will be revealed when you click see more button....................ble bla bla</span></p>
<button id="see-more-button">See more...</button>

Add this to Javascript to activate the button

Qualtrics.SurveyEngine.addOnReady(function() {
document.getElementById("see-more-button").addEventListener("click", function() {
var hiddenParagraph = document.getElementById("hidden-paragraph");
if (hiddenParagraph.style.display === "none") {
hiddenParagraph.style.display = "inline";
this.textContent = "See less...";
} else {
hiddenParagraph.style.display = "none";
this.textContent = "See more...";
}
});
});

Hope this helps


Forum|alt.badge.img+1
  • Author
  • Sep 27, 2023 7:48 PM UTC

@Vsolbiati Add this html to your question source

<style type="text/css">#hidden-paragraph {
display: none;
}
</style>
<p>The short part of the question <span id="hidden-paragraph">The hidden part that will be revealed when you click see more button....................ble bla bla</span></p>
<button id="see-more-button">See more...</button>

Add this to Javascript to activate the button

Qualtrics.SurveyEngine.addOnReady(function() {
document.getElementById("see-more-button").addEventListener("click", function() {
var hiddenParagraph = document.getElementById("hidden-paragraph");
if (hiddenParagraph.style.display === "none") {
hiddenParagraph.style.display = "inline";
this.textContent = "See less...";
} else {
hiddenParagraph.style.display = "none";
this.textContent = "See more...";
}
});
});

Hope this helps

Many thanks!! Can I use this code for more than one question or do I need to change it?


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • Sep 28, 2023 3:09 AM UTC

@Vsolbiati Add this html to your question source

<style type="text/css">#hidden-paragraph {
display: none;
}
</style>
<p>The short part of the question <span id="hidden-paragraph">The hidden part that will be revealed when you click see more button....................ble bla bla</span></p>
<button id="see-more-button">See more...</button>

Add this to Javascript to activate the button

Qualtrics.SurveyEngine.addOnReady(function() {
document.getElementById("see-more-button").addEventListener("click", function() {
var hiddenParagraph = document.getElementById("hidden-paragraph");
if (hiddenParagraph.style.display === "none") {
hiddenParagraph.style.display = "inline";
this.textContent = "See less...";
} else {
hiddenParagraph.style.display = "none";
this.textContent = "See more...";
}
});
});

Hope this helps

Many thanks!! Can I use this code for more than one question or do I need to change it?

If you showing muliple question on the same page, just throw down number behind the variable and id. Like hidden-paragraph1, hidden-paragraph2, see-more-button 1 to distinguish them.


Forum|alt.badge.img
  • Nov 16, 2026 4:22 PM UTC

I used the code above to create a ‘read more’ tab in my survey, and it worked fine when I had just one instance on the page.  However, when adding more than one ‘read more’ tab in the same page, and using numbers with the ID and variable to distinguish them as suggested above, the page opens with the read more text already open, and with the read more button appearing at the end of the paragraph.  When you click on the read more button, the text becomes hidden, and then if you re-click the ‘read more’ button it reappears, with the ‘read less’ button at the bottom. Can anyone help me solve this issue, so that the extra text is hidden at the beginning and appears for the first time when the ‘read more’ button is clicked? Thanks very much for any help - it would be greatly appreciated!