jQuery(document).ready(function() { //输入事件 $("input[id]").bind("focus",function () { if($(this).attr("id")=='username'||$(this).attr("id")=='password') $(this).attr("value",""); }); //提交 $("#submit").bind("click", function() { if (valid()) { $.ajax({ type: "POST", url: "/my/servlet/LoginServlet", data: $("form#loginform").serialize(), success: function(msg){ if(msg=='success'){ $.mobile.changePage("../index/index.html","slide",false,true); }else{ $.mobile.changePage("../message.html","slide", true, false); } } }); } }); });