我有一个非常简单的移动菜单按钮(3行),当按下时,切换菜单的显示。这不是这个元素的孩子。我使用以下包含文件:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.css" />
以下是代码:
// CAPTURE MENU BUTTON CLICK EVENT
// THIS WORKS FINE, BUT ONLY FOR THIS I NEED THE WHOLE jQueryUi AND jQueryMobile ???
$( function() {
$( "#aMenuMobile" ).bind( "tap", tapHandler );
function tapHandler( event ){
$("#tdMenuMobile").toggle();
}
});
// CAPTURE MENU BUTTON CLICK EVENT
// THIS DOESN"T WORK WELL.
$( function() {
$( "#tdMenuPc a, #tdMenuMobile a" ).bind( "tap", tapHandler );
function tapHandler( event ) {
$(window).location(event.target.href());
}
});
有没有办法让包含文件远离?特别是jQueryUi和jQueryMobile?它们会造成很多问题!
我觉得这很难看#34; loading&#34;在我的页面底部的消息。我怎么能摆脱它呢?
上面的第二个代码不能很好地运作。以下是链接的代码:
<td id="tdMenuPc">
<a href="index.php?p=home">ホーム</a>
<a href="index.php?p=german">ドイツ語</a>
<a href="index.php?p=english">英会話</a>
<a href="index.php?p=teacher">先生</a>
<a href="index.php?p=access">アクセス</a>
<a href="index.php?p=inquiry">お問い合わせ</a>
</td>
</tr>
<tr>
<td id="tdMenuMobile">
<a href="index.php?p=home">ホーム</a>
<a href="index.php?p=german">ドイツ語</a>
<a href="index.php?p=english">英会話</a>
<a href="index.php?p=teacher">先生</a>
<a href="index.php?p=access">アクセス</a>
<a href="index.php?p=inquiry">お問い合わせ</a>
</td>
大部分时间它都不起作用,或者转到&#34; index.php?p = home&#34;。我正在使用Chorme的移动模拟器。在firefox(普通浏览器)上一切正常。
提前感谢您的帮助。
我找到了一种解决方案。我的代码现在看起来像这样:
// CAPTURE MENU BUTTON CLICK EVENT
$("#aMenuMobile").on("touchend", function(ev) {
$("#tdMenuMobile").toggle();
});
$("#aMenuMobile").on("click", function(ev) {
$("#tdMenuMobile").toggle();
});
// CAPTURE MENU ITEMS CLICK EVENT
$("#tdMenuMobile a, #tdMenuPc a, #tdHeaderLinks a").on("touchend", function(ev) {
var e = ev.originalEvent;
console.log(e.target.href);
window.location.href = e.target.href;
});
但这不是我最喜欢的活动&#34; touchend&#34;。您建议哪个事件捕捉到触摸?