猿问

jquery两个错,请帮忙解决!?

1.鼠标点击第一个问题:

http://img.mukewang.com/571edb7a00011d4d07490219.jpg

2.鼠标点击第二个问题

http://img.mukewang.com/571edbe00001498511290267.jpg

qq_爱上自己_03270357
浏览 1465回答 4
4回答

qq_爱上自己_03270357

这是登录页面<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><!DOCTYPE html ><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><link rel="stylesheet" href="${pageContext.request.contextPath }/css/Loginhtwl.css" /><script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.min.js"></script><script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script></head><body> <div id="box"> <div id="login"> <form name="form" action="<%=request.getContextPath()%>/HTWLdoLoginservlet" method="post"> <p id="msg"> <% if (request.getAttribute("mess") != null) { out.print(request.getAttribute("mess").toString()); } %> </p> <input type="text" name='username' class='text username' value="请输入帐号" /> <input type="password" name='password'class='text passwrd' value="" />    <input type="button" name='sub' class='btn' value="" id="mouse" onclick="login()"/> </form> </div> </div> <script type="text/javascript"> var $username = $("[name='username']"); var $password = $("[name='password']"); $(function() { //把name得到对象 $username.focus(function() { if ($username.val() == "请输入帐号") { $username.val(""); } }); $username.blur(function() { if ($username.val() == "") { $username.val("请输入帐号"); } }); }); //提交按钮点击时 function login() { if ($username.val() == "请输入帐号" || $password.val() == "") { $("#msg").addClass("color", "red").text("用户名和密码不为空!"); } else { $("#msg").css("color", "aquamarine").text("开始登录!"); /* $("[name='form']").form.submit(); */ document.form.submit(); } } //登录 $(function(){ $(document).keydown(function(event) { if (event.keyCode == 13) { $("#mouse").click(); } }); $("#mouse").click(function() { document.form.submit(); }); }) </script></body></html>

慕莱坞9220042

你好,可以附上完整代码吗?
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答