本文介绍了JQM pagebeforechange和事件源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正在监听pagebeforechange事件...
listening to pagebeforechange event...
$(document).bind("pagebeforechange",函数(事件,数据){
$(document).bind("pagebeforechange", function ( event , data) {
//事件是从锚标记触发的...//是否可以在此处获取对anchor(或event.srcElement)的引用
//event is triggered from an anchor tag...//Is it possible to get reference to anchor( or event.srcElement) here
});
或者.....
下面是一个简单的示例,如果有人想尝试一下...
A simple sample below if somebody want to try it out...
<head>
<title>Main menu</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css"
/>
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).bind("pagebeforechange", function (event, data) {
if (typeof data.toPage === "string") {
//event is triggered from an anchor tag...
//Is it possible to get reference to anchor( or event.srcElement) here
event.preventDefault();
}
});
</script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header" data-theme="a"></div>
<div data-role="content">
<ul data-role="listview" data-inset="true">
<li>
<a href="#category-items?category=animals">Animals</a>
</li>
</ul>
</div>
</div>
</body>
</html>
推荐答案
event.liveFired.activeElement;
How about event.liveFired.activeElement;
这篇关于JQM pagebeforechange和事件源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!