我有以下简单的脚本,适用于所有浏览器和iPhone / iPad,但不适用于Android设备。我想知道如何让它与Android一起使用?
使用Javascript:
<script type="text/javascript">
<!--
// Copyright 2006-2007 javascript-array.com
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
// open hidden layer
function mopen(id)
{
// cancel close timer
mcancelclosetime();
// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';
}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
window.clearTimeout(closetimer);
closetimer = null;
}
}
// close layer when click-out
document.onclick = mclose;
// -->
</script>
HTML
<li class="test"><a href="#"
onmouseover="mopen('m4')" onmouseout="mclosetime()" class="test2">CLASSES</a>
<div id="m4"
onmouseover="mcancelclosetime()" onmouseout="mclosetime()">
<a href="http://www.anthonyteacher.com/category/2013-gall">Google</a>
<a href="http://www.anthonyteacher.com/olderclasses/">Older Classes</a>
</div>
</li>
直播:http://www.anthonyteacher.com
我尝试添加onClick =“mopen('m4')”,但这似乎不起作用。我想我需要在touchstart中使用eventhandler,但不知道如何实现它。
任何帮助?
答案 0 :(得分:0)
您可能会发现我的Houdini脚本很有用:http://cferdinandi.github.io/houdini/
<强>更新强>
要在点击和悬停时进行此工作,请抓住jQuery版本。在第14行,更新:
$('.collapse-toggle').click(function(e) {
改为说:
$('.collapse-toggle').on('click hover', function(e) {