jQuery: how to refresh DOM after fading in new elements? -


i want make small survey. want user has answer questions. new question fading in after clicking answer. works 1 time, because new question on display:hidden before not in dom think. need refresh dom think?

here example: http://jsfiddle.net/x2yu6tvw/

qstnno = $('.question').data('id');  $('.answer').on( 'click', function(){     $('.question[data-id="' + qstnno + '"]').fadeout(800, function(){         nextqstn = qstnno+1;          $('.question[data-id="' + nextqstn + '"]').delay(300).fadein(300);      }); }); 

what can jquery listen new added element?

here working demo.

js

$('.answer').on( 'click', function(){     qstnno = $(this).parent('div').data('id');     $('.question[data-id="' + qstnno + '"]').fadeout(800, function(){         nextqstn = qstnno+1;          $('.question[data-id="' + nextqstn + '"]').delay(300).fadein(300);      }); }); 

issue: qstnno value not correct in case. should dynamic not fixed.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -