使用jQuery的问题 [英] Problem working with jQuery

查看:126
本文介绍了使用jQuery的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,jQuery不工作,我想知道问题是什么。这是我的代码:

 < script language =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js>< / script> 
< script language =text / javascript>
function hide(){
$(#Layer1)。hide(fast);
}
< / script>
< style type =text / css>
<! -
body {
background-color:#000000;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left:179px;
顶部:3px;
}
#Layer2 {
position:absolute;
width:101px;
height:80px;
z-index:2;
左:570px;
顶部:473px;
}
- >
< / style>< / head>
< body>
< div id =Layer1>< / div>
< div id =Layer2onclick =hide()>< / div>
< / body>
< / html>

谢谢! :

解决方案

您似乎对脚本的形式感到困惑标签:

 < script type =text / javascript> 

与之相符:

 < script language =javascript> 

(参见例如这里为某些解释)。为什么不修复标签才能使用 type = ?不知道这是否是你的问题(在发现这个问题之后,我认为即使有其他人也需要修复),但是它让我感到困惑,可能会让你的浏览器感到困惑; - )


jQuery for some reason isn't working.I'd like to know what the problem is.Here is my code :

<script language="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>    
<script language="text/javascript">
function hide() {
    $("#Layer1").hide("fast");
}
</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:101px;
 height:80px;
 z-index:2;
 left: 570px;
 top: 473px;
}
-->
</style></head>
<body>
<div id="Layer1"></div>
<div id="Layer2" onclick="hide()"></div>
</body>
</html>

Thanks! :)

解决方案

You seem to be confusing the form of the script tag that goes:

<script type="text/javascript">

with the one that goes:

<script language="javascript">

(see e.g. here for some explanation). Why not fix your tags to use just type= instead? Not sure whether that's all your problem (after spotting this one I think it needs to be fixed even if there were others;-) but it's confusing me and could be confusing your browser;-).

这篇关于使用jQuery的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆