Django Jquery Not Working?
This is what my template looks like: {% extends 'typer/base.html' %} {% load url from future %} {% load staticfiles %} {% block title %}{{ p_name }}{% endblock %} {% block body_
Solution 1:
you need $(function(){ ... })
(or $( document ).ready(function() { ... });
which is equal, only longer) around your js code:
so:
$(function(){
$('#user_passage_text').on('keyup', function(e) {
if ( e.which === 13 ) {
var time = (newDate()).getTime() - $(this).data('time');
$(this).data('time', 0);
console.log('Time passed : ' + time + ' milliseconds');
}elseif ( !$(this).data('time') ){
$(this).data('time', (newDate()).getTime());
}
});
});
fiddle is working because you set it to onload
which is almost equal to $(function(){ ... })
here.
Post a Comment for "Django Jquery Not Working?"