jQuery不起作用:处理指令未关闭 [英] jQuery not working: Processing instruction not closed
问题描述
JSP代码是:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ include file="headpl.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script>
$(document).ready(function(){
$('#editform').hide();
$("#clickedit").click(function(){
$("#editform").toggle(500);
});
});
</script>
</head>
<body>
<hr width="1" size="600" style="position:absolute; left:450px; top:250px;" />
<div id=edit style="position:absolute; left:100px; top:600px;">
<p><a id="clickedit" href="">Edit personal details </a></p>
</div>
<div id=editform style="position:absolute; left:100px; top:650px;">
<form>
<p>First name: <input type="text" name="fname" value="<%=request.getAttribute("fname")%>" required/>
</p>
<p>Last name: <input type="text" name="lname" value="<%=request.getAttribute("lname")%>"/>
</p>
<p>E-mail:
<input type="email" name="email" value="<%=request.getAttribute("email")%>"/>
</p>
<p>State:
<input type="text" name="state" value="<%=request.getAttribute("email")%>"/>
</p>
<p>
<input type="submit" value="Save changes"/>
</p>
</form>
</div>
</body>
</html>
jQuery代码无法正常工作.日食之前显示了一个错误:
The jQuery code isn't working. The eclipse was earlier showing an error:
处理指令未关闭.
Processing instruction not closed.
但是我做了Ctrl + A->退格键-> ctrl + Z
But I did Ctrl+A -> Backspace -> ctrl+Z
该错误已删除,我不知道如何,但该错误消失了.
and the error was removed I don't know how, but the error vanished.
但是jQuery代码仍然无法正常工作.我没有看到任何错误,但是有些人会吗? 我知道问题的程度很低,但是我尝试了很长时间,也看了其他类似的问题,但是没有任何效果.
But still the jQuery code isn't working. I don't see any error, but some of you would? I know the ques is way to low but I was trying for a long time, looked other similar questions as well but nothing is working.
推荐答案
您需要禁用跟踪链接的默认操作,即重新加载页面.
You need to disable the default action of following the link, which is reloading the page.
$(document).ready(function () {
$('#editform').toggle();
$("#clickedit").click(function (e) {
e.preventDefault();
$("#editform").show();
});
});
这篇关于jQuery不起作用:处理指令未关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!