jquery - Bootstrap Modal popup not scrolling with keyboard -
i'm using bootstrap modal, added scroll bar , works fine mouse, when use keyboard background page scrolls. can solve this. css code i'm using.
.modal .modal-body { height: 520px; overflow-y: auto; }
i tried code doesn't work
$('#mymodal').keydown(function(e) { if(e.keycode == 40){$('.modal-body').scrolltop($('.modal-body').scrolltop()+10);} if(e.keycode == 38){$('.modal-body').scrolltop($('.modal-body').scrolltop()-10);} });
keystrokes detected element has focus, keydown
event won't trap if focus on element in background. suggest doing following:
- making modal focusable giving
tabindex=-1
attribute - setting have focus when opens, this: $("#my-modal").focus()
Comments
Post a Comment