javascript - 功能不适用于网络浏览器中的模态

标签 javascript php jquery

我有问题我的功能在移动浏览器中不起作用但是当我在浏览器桌面工作时打开我不知道为什么......也许有人知道或有像我这样的经验 我试过这段代码

$('body').on('click touchstart', '.show_range', function(event) { alert("hello"); })

在桌面上工作但不能在移动浏览器上工作

当我在我的链接中设置 id 时,我已经尝试过这段代码

$(document).on("click", "#show_range", function(event){
 alert( "GO" ); 
 });

在桌面上工作但不能在移动浏览器上工作

最佳答案

如果你使用的是 bootstrap modal,那么做一些如下的改变,

在 bootstrap-responsive.css 中

.modal { 
    position: fixed; 
    top: 3%; 
    right: 3%; 
    left: 3%; 
    width: auto; 
    margin: 0; 
}
.modal-body { 
    height: 60%; 
}

在 bootstrap.css 中

.modal-body { 
    max-height: 350px; 
    padding: 15px; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
 }

或 试试这个,

if( navigator.userAgent.match(/iPhone|iPad|iPod/i) ) {
    var styleEl = document.createElement('style'), styleSheet;
    document.head.appendChild(styleEl);
    styleSheet = styleEl.sheet;
    styleSheet.insertRule(".modal { position:absolute; bottom:auto; }", 0);
 }

关于javascript - 功能不适用于网络浏览器中的模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40541147/

相关文章:

javascript - 如何从 google 脚本将值传递到 html 页面

javascript - 带有 JavaScript 的编程 Python 浏览器

javascript - 在 React 中删除 body 的边距

javascript - 使用Ajax从javascript发送数组到php,不使用表单

php - 在几个php页面之间传递一个数组

PHP 从字符串中删除域名

javascript - JQuery if 语句未正确检测跨度复选框

javascript - Ember.js 待办事项应用程序 Handlebars 模板问题

php - 如何通过 HTTP header 使用另一台服务器登录 PHP 脚本?

javascript - Froala的所有工具栏按钮