0

I'm trying to add a "previous question" button on a quiz I'm making. After the user answers the first question, I add in a <button class="prevquestion">, however, when I have the jquery event $(.prevquestion).onClick..., the code isn't triggered (using chrome javascript debugger) even when the prev class button is added.

I assume this is because jQuery only notices elements on the page when the page loads, so how should I go about allowing the prevquestion button to trigger an onClick event?

This is pseudocode so some syntax may be off, the button click is working for nextquestion, just not prevquestion.

Thanks!

google1254
  • 157
  • 3
  • 13
  • use `.on('click', function(){});` More info here: http://stackoverflow.com/questions/12627443/jquery-click-vs-onclick – Dan Aug 26 '14 at 20:18
  • Try using `$('.prevquestion').click(function() { //event });` http://api.jquery.com/click/ – Kevin Vess Aug 26 '14 at 20:20
  • If your code is exactly as shown you then you need to change `$(.prevquestion)` to `$('.prevquestion')` because you forgot the string quotes. – Anton Aug 26 '14 at 20:25

0 Answers0