本文介绍了jQuery函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Shout!</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var status=1;
function action() {
if(status==1) {
$("#Layer1").hide("slow");
$("#Layer3").hide("fast");
$("#Layer4").hide("slow");
$("#close").attr("src","open.jpg");
status=0;
}
else if(status==0) {
status=1;
$("#Layer1").show("slow");
$("#Layer3").show("fast");
$("#Layer4").show("slow");
$("#close").attr("src","close.jpg");
}
}
function sendline() {
$("#msg").val(" ");
}
function type() {
var text=$("#msg").val();
$("#Layer6").html(text);
}
</script>
<style type="text/css">
<!--
body {
background-color: #000000;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 179px;
top: 3px;
}
#Layer2 {
position:absolute;
width:69px;
height:64px;
z-index:2;
left: 570px;
top: 543px;
}
#Layer3 {
position:absolute;
width:124px;
height:22px;
z-index:3;
left: 473px;
top: 474px;
}
.style1 {
color: #FFFFFF;
font-family: "Segoe UI";
font-weight: bold;
}
#Layer4 {
position:absolute;
width:72px;
height:27px;
z-index:4;
left: 744px;
top: 485px;
}
#Layer5 {
position:absolute;
width:274px;
height:70px;
z-index:5;
left: 422px;
top: 62px;
}
#Layer6 {
position:absolute;
width:638px;
height:356px;
z-index:5;
left: 272px;
top: 105px;
}
-->
</style></head>
<body>
<div class="style1" id="Layer3">
<textarea id="msg" style="height:50px;width:250px" rows="10" cols="80" onkeyup="type()"></textarea></div>
<div id="Layer1">Hello World!<img src="body.jpg" alt="Shout !" width="842" height="554" /></div>
<div id="Layer2"><img src="close.jpg" id="close" width="63" height="64" OnClick="action()"/></div>
<div id="Layer4">
<input type="button" value="Send Line" onclick="sendline()" /></div>
<div id="Layer6" style="color:#FFFFFF;"></div>
</body>
</html>
我遇到了type()函数的问题,它根本没有运行
I'm facing a problem with the type() function.Its simply not running
关于如何得到它的任何建议吗?
Any advice on how to get it rnnning?
谢谢!
推荐答案
您的函数正在运行,但是由于函数名而引发错误:
Your function is running, however it's throwing an error because of the function name:
或在Firefox中:
or in Firefox:
简而言之,您不能在此处使用type
作为函数名称,您只需要给它一个稍有不同的名称即可,例如typed
.
In short, you can't use type
as a function name here, you just need to give it a slightly different name, for exampled typed
.
这是您的代码,仅 更改函数名称,可以正常工作: )
Here's your code only changing the function name, working :)
这篇关于jQuery函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!