【发布时间】:2011-11-02 23:50:08
【问题描述】:
我认为焦点事件不适用于 JQuery mobile:这是我的代码。 (当我删除对库 jquery mobile 的调用时,它可以工作)
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function() {
$('#acceuil').live('pagecreate', function(event) {
$('#declencher').click(function() {
$('#cache').focus();
});
$('#declencher').trigger('click');
});
});
</script>
<body>
<div data-role="page" id ="acceuil" >
<div data-role="header" data-theme="a" ><h3>aaa</h3></div>
<div data-role="content">
<input id="cache" type="input">
<input type="button" id="declencher" value="declencher">
</div><!-- content-->
<div data-role="footer" data-theme="a" data-position="fixed"><h3> Footer </h3></div>
</div>
</body>
</html>
【问题讨论】:
-
更干净的问题通常会得到更快的回答......
-
你试过删除
$(document).ready()吗?按照文档中的建议,您应该将事件绑定到pagecreate而不是document.ready。 -
谢谢你的写作,我想我的问题很清楚!我已删除 $(document).ready() 但它不起作用,我认为 jquery mobile 不支持 focus()
-
我没有说你的问题不清楚。我说它没有干净地呈现(即“干净”与“清晰”)。我编辑了您的问题并整理了您的代码,您可以通过查看编辑历史来检查。
-
这篇文章有帮助吗:stackoverflow.com/questions/5889424/…?
标签: jquery jquery-ui jquery-plugins jquery-selectors jquery-mobile