How to make an image disappear after a few seconds but the question next to it stays displayed | Experience Community
Skip to main content
Solved

How to make an image disappear after a few seconds but the question next to it stays displayed

  • Dec 31, 2020 2:40 PM UTC
  • 4 replies
  • 893 views

Hello!
I would be very happy for your help!!
I'm looking for how to make an image disappear after a few seconds but the question next to it to stay displayed until the participant finishes the rating.
I tried to use the timer option, but I need the question to appear next to the image both when the image is displayed and afterwards. That is, I want an image to be displayed next to a rating question, and after 3 seconds i want the image to disappear but the question to remain displayed until the participant finishes rating.
thank you very much!!

Best answer by TomG

You'll need to use JavaScript's setTimeout() function to hide the image after 3000 milliseconds. Add something like this to the rating question's addOnReady function:
var img = jQuery("#"+this.questionId+" img");
setTimeout(function() { img.hide(); },3000);

View original

4 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • Dec 31, 2020 3:04 PM UTC

You'll need to use JavaScript's setTimeout() function to hide the image after 3000 milliseconds. Add something like this to the rating question's addOnReady function:
var img = jQuery("#"+this.questionId+" img");
setTimeout(function() { img.hide(); },3000);


  • Author
  • Dec 31, 2020 3:53 PM UTC

it worked! 😊
Thank you very much!


  • Feb 27, 2021 6:58 PM UTC

TomG
Hi! Could you advise how to change the code so as I can replace the image with another (instead of hiding it)? Thank you.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Feb 27, 2021 7:38 PM UTC

https://www.qualtrics.com/community/discussion/comment/35060#Comment_35060I haven't tried this, but try replacing the image's src attribute.
var img = jQuery("#"+this.questionId+" img");
setTimeout(function() { img.attr("src","url of image goes here"); },3000);