Search code examples
javascriptqualtrics

Qualtrics, next button appear after video started


I'm new with Qualtrics, and I'm wondering if there is a way of creating a rule with javascript for the next button to appear only if a video is played or when fully watched?

I have this code but only with a timer

Qualtrics.SurveyEngine.addOnReady(
    function() { 
        var delayTime = 7000 //This is the time of delay
        var that = this; 
        $('NextButton').hide();
        $('PreviousButton').hide();
        setTimeout(function(){ 
           $('NextButton').show();
           $('PreviousButton').show();
        },
        delayTime
        );
    });

Thanks in advance


Solution

  • Are you using an html5 video tag? If so, you can use an 'ended' handler:

    jQuery("#"+this.questionId+" video").on("ended", function() {
          $('NextButton').show();
          $('PreviousButton').show();
    });