未链接的按钮和链接按钮不';t在jQuery Mobile中显示点击动画/状态更改
我试图在使用jQuery mobile的移动应用程序中使用未链接的按钮。我仍然希望按钮是可点击的,但是我希望使用自己的按钮,而不是默认的ajax行为 然而,当我点击一个没有链接的按钮时,它不会给出任何反馈。也就是说CSS不会更改为按下状态,然后再返回。当我点击一个包含有效href或在表单中的链接时,它会工作 奇怪的是,在我的桌面浏览器中点击链接确实会引起变化,尽管这与点击按钮不同。使用默认CSS软件包,点击按钮提交表单或进入下一页时,按钮会立即变为蓝色。当我在桌面上点击它们时,它们会进入灰色的悬停状态,所以在任何浏览器上都不起作用 有人知道如何让一个简单的按钮响应点击,即使按钮实际上没有链接到任何地方吗 编辑:这里有一些代码可以尝试,我在iOS和Android上都试过了,结果是一样的未链接的按钮和链接按钮不';t在jQuery Mobile中显示点击动画/状态更改,mobile,button,jquery-mobile,Mobile,Button,Jquery Mobile,我试图在使用jQuery mobile的移动应用程序中使用未链接的按钮。我仍然希望按钮是可点击的,但是我希望使用自己的按钮,而不是默认的ajax行为 然而,当我点击一个没有链接的按钮时,它不会给出任何反馈。也就是说CSS不会更改为按下状态,然后再返回。当我点击一个包含有效href或在表单中的链接时,它会工作 奇怪的是,在我的桌面浏览器中点击链接确实会引起变化,尽管这与点击按钮不同。使用默认CSS软件包,点击按钮提交表单或进入下一页时,按钮会立即变为蓝色。当我在桌面上点击它们时,它们会进入灰色的悬
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0-beta.1/jquery.mobile-1.2.0-beta.1.min.css" />
<script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0-beta.1/jquery.mobile-1.2.0-beta.1.min.js"></script>
</head>
<body>
<div data-role="page" id="startpage">
<div data-role="header" data-theme="c">
<h1>Button Test</h1>
</div>
<div data-role="content">
<button id="test1">Test 1</button>
<button data-role="button" id="test2">Test 2</button>
<a data-role="button" id="test3">Test 3</a>
<a data-role="button" href="" id="test4">No href</a>
<a data-role="button" href="#" id="test5">href=#</a>
<a data-role="button" href="#page2" id="test6">This works because it's linked</a>
<form method="get" action="index2.html">
<input type="text" name="name" placeholder="Name"/>
<button type="submit" value="No tap change here either"></button>
</form>
</div><!-- /content -->
</div><!-- /page -->
<div data-role="page" id="page2">
<div data-role="header" data-theme="c">
<h1>Page 2</h1>
</div>
<div data-role="content">Linked buttons work</div>
</div>
</body>
</html>
我的页面
按钮测试
测试1
测试2
第2页
链接按钮起作用
好的,我在jQuery移动问题跟踪器中发现了一个bug,这似乎是一个已知的问题
https://github.com/jquery/jquery-mobile/issues/4469
解决方法是使用如下链接按钮:
<a href="javascript:void(0)" data-role="button">Click me</a>
这样,按钮将向用户提供反馈,即使它实际上不去任何地方或做任何事情
他们正在研究在v1.3中修复此问题。Hi!你能提供一些代码吗?是的,增加了一个例子。即使表单提交按钮也不会更改为点击状态。这适用于大多数情况: