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

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

  • 31 December 2020
  • 4 replies
  • 421 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!!

icon

Best answer by TomG 31 December 2020, 16:04

View original

4 replies

Userlevel 7
Badge +27

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);

it worked! 😊
Thank you very much!

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.

Userlevel 7
Badge +27

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);

Leave a Reply