I am a Chinese!My English is bad,but I have a trouble about JQuery Mobile!I hope that foreign friend can help me.The Question is below!
first:At the first.jsp,Click the 'General Button' is OK.but the 'Submit Button' is not OK.Why?? second:Click the 'Link Button',navigate to second.jsp,click the 'Test' button.the javascript code is not execute!
I do not know Why they happen!Can you help me!Thank you.
first.jsp
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>China</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.css" />
<script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery-1.4.4.js"></script>
<script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.js"></script>
<script>
$(function(){
$('#Button').click(function(){
alert('This is a general button!');
});
$('#ButtonSubmit').click(function(){
alert('This is a submit button!');
});
});
</script>
</head>
<body>
<div id="page" data-role="page" data-theme='d'>
<div data-role="header" data-position="inline" data-position="fixed">
<h1>Chinese</h1>
</div>
<div data-role="content">
<a id="Button" data-role='button' data-iconpos="right" data-icon="gear">General Button</a>
<a id="ButtonSubmit" data-role='button' data-iconpos="right" type="submit" data-icon="gear">Submit Button</a>
<a id="link" href="/mobile/mobile/second.jsp" data-role='button' data-iconpos="right" data-icon="gear">Link Button</a>
</div>
<div data-role="footer" data-position="fixed">
<h1>[Email:zhaosheng.wolf@163.com][1]</h1>
</div>
</div>
</body>
</html>
second.jsp
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>China</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.css" />
<script type="text/javascript" src="/mobile/mobile/common/script/jQuery/jquery-1.4.4.js"></script>
<script type="text/javascript" src开发者_运维百科="/mobile/mobile/common/script/jQuery/jquery.mobile-1.0a2.js"></script>
<script>
$(function(){
$('#test').click(function(){
alert('This is a general button!');
});
});
</script>
</head>
<body>
<div id="page" data-role="page" data-theme='d'>
<div data-role="header" data-position="inline" data-position="fixed">
<h1>[Chinese][2]</h1>
</div>
<div data-role="content">
<a id="test" data-role='button' data-iconpos="right" data-icon="gear">Test</a>
</div>
<div data-role="footer" data-position="fixed">
<h1>Email:zhaosheng.wolf@163.com</h1>
</div>
</div>
</body>
</html>
[1]: http://zhaosheng.wolf@163.com
[2]: http://zhaosheng.wolf@163.com
Remove type="submit"
in #ButtonSubmit
And if u like to style your button, so it looks like a button, take a look at her.
The jQuery Mobile uses ajax to change of page, and you need a live() or delegate() to event "pageshow" or other for run when this event call.
精彩评论