出于某种原因,jQuery和Javascript在我的网站上无效。
见这里:http://hellomynameisad.am/test.html
有人能够达到巅峰并让我知道自己错过了什么吗?我尝试了很多不同的jQuery代码,似乎没什么用。谢谢。
答案 0 :(得分:3)
您需要将document.ready设置为使html元素能够执行javascript,或者您可以在结束正文标记之前放置脚本。
<强> Live Demo 强>
$(document).ready(function(){
$("#container").fadeOut(function() {
$(this).text("World").fadeIn();
});
});
编辑:我发现html中的其他错误很少见。
更改HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.js "> </script>
<title>Untitled Document</title>
<style type="text/css"> </style>
<script type="text/javascript">
$(document).ready(function(){
$("#container").fadeOut(function() {
$(this).text("World").fadeIn();
});
});
</script>
</head>
<body>
<div id="container">Hello</div>
</body>
</html>
答案 1 :(得分:-3)
请添加此
<script>
$(document).ready(function(){
$("#container").fadeOut(function() {
$(this).text("World").fadeIn();
});
});
</script>
在</body>
结束后看到它运行的部分代码。