Why my jQuery for the #NextButton does not work? | XM Community

Why my jQuery for the #NextButton does not work?

  • 9 October 2019
  • 3 replies
  • 143 views

Userlevel 5
Badge +6
  • Level 3 ●●●
  • 197 replies
Hi all,
I tried to implement an onclick function for the next button in a survey which was designed using the old Look&feel editor (theme: Minimal - blue).
MWE: `jQuery( "#NextButton" ).click(function() {alert("OK");});`

I tried to solve this and wasn't succesful, but I found out following:

1. Other codes using this jQuery also doesn't work (e.g.: `jQuery(".NextButton").css("background-color", "yellow!important");` or `jQuery(".NextButton").hide();`)
2. Using the classname instead of the ID didn't help.
3. ID and class names were correct for actual survey. (I've checked this using inspector)
4. There are no errors in the console log (in both Mozilla and Chromium).
5. jQuery for other elements

Would anyone have some suggestions what else could I check or try? I'd appreciate also some other ways how to create a function which will run after clicking on the next button.
Thanks for any suggestions!

3 replies

I also met this problem. The following js code doesn't work. I am quite confused.
jQuery("#NextButton").click(function()

Userlevel 7
Badge +27

fleb's issue from 10/19 was probably a timing issue.
Yanan - Attaching a click handler to the Next button can cause conflicts. You would be better off using the addOnPageSubmit() function.

https://www.qualtrics.com/community/discussion/comment/31498#Comment_31498Thanks for your suggestion! However, I have something more complicated that may not be able to achieve using just addOnPageSubmit() function. Could you help me with this post? Thank you very much!
https://www.qualtrics.com/community/discussion/13029/how-to-use-js-to-insert-the-question-number-when-using-question-randomization-within-block

Leave a Reply