jQuery event not working on dynamically loaded elements -


i loading element through jquery ajax id questionbeanpv.coappquestions150.answertext know id long , contains jquery's '.' cannot change id.

i want funnction called when element clicked. following code not working.

$(document).ready(function(){            $('#questionbeanpv\\.coappquestions150\\.answertext').click(function(){         alert('hello !');     }); }); 

i have observed doesnt work dynamically loaded element. missing ? correct way or other way there?

you can use event delegation here:

$('body').on('click', '#questionbeanpv\\.coappquestions150\\.answertext', function() {     alert('hello !'); }); 

this technique helps attach event dynamically created elements.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -