是否有一个jQuery插件或JavaScript脚本能够自动遍历每个CSS悬停(在外部样式表中找到)并将其绑定到一个双触地事件中?
如果还没有这样的东西,它能做吗?如何(指导方针)?
编辑:
要说清楚的是,我不是在寻找双击。触地得分1是一个标签,就像触地得分2一样。两者之间的时间可以少于0秒,也可以长达3分钟,这是用户的选择。
无触碰:
触摸(iOS):
发布于 2011-04-05 21:30:07
试试这个:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>iPad Experiment</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
if(navigator.platform == "iPad") {
$("a").each(function() { // have to use an `each` here - either a jQuery `each` or a `for(...)` loop
var onClick; // this will be a function
var firstClick = function() {
onClick = secondClick;
return false;
};
var secondClick = function() {
onClick = firstClick;
return true;
};
onClick = firstClick;
$(this).click(function() {
return onClick();
});
});
}
});
</script>
<style type="text/css">
a:hover {
color:white;
background:#FF00FF;
}
</style>
<body>
<a href="http://google.ca">Google</a>
<a href="http://stackoverflow.com">stackoverflow.com</a>
</body>
</html>..。或者看看在我的网站上演示。请注意,它只在iPad上运行它的魔力--检测iOS的所有版本是我书中的另一个问题;)
它的作用是基于这样一个事实..。
在您单击iphone或ipad上的链接后,它会留下一个模拟鼠标悬停,触发该链接上的a:悬浮css样式。如果链接具有使您保持在同一页上的javascript处理程序,则在单击另一个链接之前,悬停状态不会更改。
发布于 2011-04-06 08:33:42
我用过这个:
$(document).ready(function() {
$('.hover').bind('touchstart touchend', function(e) {
e.preventDefault();
$(this).toggleClass('hover_effect');
});
});之前,允许在某些元素上悬停。显然,您需要调整它供您自己使用,但这是一个很好的方式,允许触摸和保持悬停效果。
发布于 2012-03-16 04:10:56
下面是一个进一步优化的版本,它还处理关闭“悬停”
必须将站点封装为
<div id="container"></div>才能发挥作用。把闭幕式放在身体上什么也没做
var bodyBound = false;
var container;
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i))
{
container = $("#container");
// Provoke iOS :hover event
$("a.someLink").on("mouseover", handleHoverClick);
}
function handleClose(event)
{
container.off("click", handleClose);
bodyBound = false;
}
function handleHoverClick(event)
{
if (!bodyBound)
{
bodyBound = true;
// Somehow, just calling this function—even if empty—closes the :hover
container.on("click", handleClose);
}
}https://stackoverflow.com/questions/5507964
复制相似问题