- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在之前的元素中,使用 touchstart 和 touchend 事件修改按钮的 css 的以下代码没有问题:
<script>
$('input[type="button"]').on('touchstart', function(e){
$(this).css('background-color','#49D623');
});
$('input[type="button"]').on('touchend', function(e){
$(this).css('background-color','');
});
</script>
这是在使用 2.9.0 版的 iOS cordova 元素中
因为我已经升级到 cordova 3.2 并且正在使用 jquery mobile 1.4.0 和 jquery 1.10.2,所以上面的代码不再有效。
我已经尝试过 .on(touchstart
和 .bind(touchstart
和 .live(touchstart
与 jquery 1.8 一起工作但在 1.9 中被弃用.我也尝试过使用按钮的id,但那也不起作用。
我知道 touchstart 正在被识别,因为我已经测试过它可以触发其他功能,而且它的效果非常好,但不是为了这个。
这是按钮在我的 html 中的显示方式:
<input type="button" id="submit" data-role="none">
相关按钮的CSS:
input[type="button"] {
-webkit-appearance: none;
border-radius: 0px;
width: 92%;
margin-top: 3%;
margin-left: 5%;
background-color: rgba(23,24,54,1.00);
padding: 10px;
border-width: 1px;
border-color:rgba(88,88,88,1.00);
font-size: 1em;
color: #FFFFFF;
font-family: 'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
background-image: url(../img/padlock2.png);
background-size: 20px;
background-repeat:no-repeat;
background-position: 50% 50%;
}
我的 html 文件的头部引用了以下内容:
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.mobile-1.4.0.min.js"></script>
<script src="cordova.js"></script>
<script src="cordova_plugins.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquerymobile1.4rc1.css">
<link rel="stylesheet" type="text/css" href="css/login.css">
<link rel="stylesheet" type="text/css" href="css/globalstyles.css">
我在这里错过了什么?
最佳答案
我不确定它是否能解决您的问题,但 .live() 方法已被弃用。尝试使用 .on() 方法代替它。还可以尝试用 mousedown 和 mouseup 替换 touchstart 和 touchend,看看是否能解决问题。这是一个plunker where i got something similar to work
关于javascript - Touchstart 和 touchend 不能在 iOS 上使用 jquery mobile 和 cordova,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21093816/
这是我的代码,以防 touchend 事件发生: $('body').on('click touchend', '.typeSelect', function(){ var Classes =
基本上我有这个移动菜单Link (请调整窗口大小以查看移动菜单)。问题在于,在移动设备上,用户通常会向下滑动来查看内容。手机上的主菜单。松开手指而不是第一次触摸时,有什么方法可以激活菜单的“点击”?问
对于在 touchend 事件期间衡量一个元素是否在另一个元素(视觉上)的最佳方法感到困惑。本质上,我正在实现触摸友好的拖放操作。 我看过一些关于 .elementFromPoint() 和 even
这是我第一次处理触摸事件。我正在制作一个按钮,用于在响应式网络上滑动侧面菜单。该按钮应该只显示 touchstart 事件存在,并在 touchend 事件触发后 500 毫秒消失。 这是我的代码:
在 HTML5、CSS3 和 jQuery 的帮助下创建的示例移动应用程序。在应用程序中列出了带有右箭头标记的用户详细信息数量。箭头标记有 touchend 事件。哪个触摸端处理程序导航到下一个屏幕。
我正在运行一个简单的 OpenGL:ES 应用程序(它是一个游戏)。游戏加载并向用户显示“新游戏按钮”,然后您就进入游戏了。我使用 TouchBegan/TouchEnded 来处理触摸。然后我获取坐
是否可以删除touchend 的active 状态?我想通过点击链接来设置链接的事件状态。当然,在我的移动设备中滚动时,我触摸的每个元素都会获得 :active 状态。因此,滚动后所有元素都会突出显示
我想做两件事...当我们触摸屏幕和从屏幕上释放手指时做一些事情。但是下面的 touchend 函数甚至在我释放手指之前就会触发警报框。我错在哪里? $(window).on('touchend', f
我注意到触摸事件中有一个奇怪的行为。情况是这样的:我有一个#pointercapture div,默认情况下是隐藏的。 touchstart 处理程序附加到主体,这会导致 pointercapture
我有一个带有 div 的简单列表(在 iOS 上)。我在列表元素上使用 touchend 事件来执行操作。我这样做是因为 click 事件有大约 500 毫秒的延迟,这让 UI 感觉迟钝。 但是,当我
我有 3 个节点数组,每个数组有 5 个节点。本例中的节点是正方形。 我想使用 touchesBegan 和 touchesEnded 移动它们,保存用户触摸的数组,然后保存手指从屏幕上移开时的位置。
我将 AngularJS 与 Ionic Framework 结合使用。我正在开发实时通信应用程序。 我有一个范围 slider ionic docu .如果我使用 ng-change 每一步都会调用
我有一些代码可以更改表的类。在手机上,有时表格对于屏幕来说太宽了,用户会拖动/滚动来查看内容。但是,当他们触摸并拖动表格时,它会在每次拖动时触发 touchend。 如何测试触摸端是否是触摸拖动的结果
看完这篇event_touchcancel文档: The touchcancel event occurs when the touch event gets interrupted. Differe
我在 ul 的 li 之间使用拖放操作。代码在桌面版本上运行良好。 A A C D E 但是对于移动版本,我得到了多个触摸端 li.addEventListener(
我试图为我为 iPhone 开发的绘图应用程序实现手掌拒绝功能,并注意到触摸事件中有一些奇怪的行为。当我将手掌放在屏幕上并不断抬起手的某个区域然后再次放下时,我会收到很多 touchBegin 事件,
我构建了一个处理 touchstart 的 slider , touchend和 touchmove事件。 它在 Android 和 iOS 上运行良好。 只有当我将 iOS 上的手指慢慢移出屏幕时,
如果元素“#menu”被触摸,我想获取 touchstart 和 touchend 位置。 我写了这段代码,但事件似乎根本没有触发: var lastLoc = 0;
最近我开始在 javascript 中玩触摸事件,我遇到了一个奇怪的 touchend 事件问题(可能是很明显的问题,但我太笨了,无法理解)。所以基本上,这是我的代码: function send(e
我一直在为我的主页开发一个移动网站,但在连接到移动触摸事件时遇到了问题。基本上我想完成以下任务: 用户向下滚动 触发 touchend 事件 --> 调用一个函数来计算滚动后隐藏在上方的文档的数量(如
我是一名优秀的程序员,十分优秀!