Javascript jQuery移动Ajax(不执行js)
我是中国人!我的英语不好,但是我在JQuery手机方面遇到了麻烦!我希望 外国朋友可以帮助我。问题如下 首先:在first.jsp中,单击“常规按钮”可以。但是“提交按钮”不可以。为什么?? 第二:单击“链接按钮”,导航到second.jsp,单击“测试”按钮。javascript代码不会执行 我不知道为什么会这样!你能帮助我吗!多谢各位Javascript jQuery移动Ajax(不执行js),javascript,jquery,ajax,mobile,Javascript,Jquery,Ajax,Mobile,我是中国人!我的英语不好,但是我在JQuery手机方面遇到了麻烦!我希望 外国朋友可以帮助我。问题如下 首先:在first.jsp中,单击“常规按钮”可以。但是“提交按钮”不可以。为什么?? 第二:单击“链接按钮”,导航到second.jsp,单击“测试”按钮。javascript代码不会执行 我不知道为什么会这样!你能帮助我吗!多谢各位 first.jsp <!DOCTYPE html> <%@ page contentType="text/html;charset=UTF-
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>
<!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
删除按钮提交中的type=“submit”
如果你想设计你的按钮的样式,使它看起来像一个按钮,看看。删除type=“submit”
中的#按钮提交
如果你想设计你的按钮,让它看起来像一个按钮,看看。jQuery Mobile使用ajax来更改页面,你需要一个live()或delegate()来调用事件“pageshow”,或者在这个事件调用时运行其他程序。jQuery Mobile使用ajax来更改页面,你需要一个live()或delegate()来调用事件“pageshow”或此事件调用时运行的其他命令。$(函数(){$('#测试')。单击(函数(){alert('这是一个常规按钮!');});我想知道为什么没有添加“second.jsp”页面“Test”按钮点击事件?为什么?看起来javascript代码没有执行;你能告诉我发生的原因吗?我已经阅读了jquery-moible.js的源代码。似乎方法innerHTML()和jquery的方法wrap()可以导致执行javascript代码。请尝试编辑#测试:单击她,发生了什么事?$(function(){$('#test')。单击(function(){alert('这是一个常规按钮!'); }); });我想知道为什么没有添加“second.jsp”页面“Test”按钮点击事件?为什么?看起来javascript代码没有执行;你能告诉我发生的原因吗?我已经阅读了jquery-moible.js的源代码。似乎方法innerHTML()和jquery的方法wrap()可以导致javascript代码被执行。试着编辑#测试:单击她,发生了什么?