Home >Web Front-end >JS Tutorial >Solve the problem that modal in bootstrap cannot close the page when it encounters the Esc key_javascript skills

Solve the problem that modal in bootstrap cannot close the page when it encounters the Esc key_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:11:001367browse

Bootstrap provides us with many convenient page controls, modal is one of them. Many people have encountered the problem that modal cannot be closed by pressing the esc key, and it does not take effect even if the keyboard option is explicitly passed in.

$('#editFormItemModal').modal({show:true, keyboard:true});

This problem occurs in versions 2.1 and later. It is very simple to solve this problem. Just add a tabindex attribute to the div where the modal is located:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn