我對jQuery和JavaScript一般都很陌生,所以也許我錯過了一些東西。jQuery適用於Firebug控制檯,但不適用於頁面加載
我有一個鏈接到頭部的最新版本的jQuery的html頁面...
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
但任何jQuery的代碼,我嘗試任何地方執行......在頭部或獨立.js文件,當我加載頁面時不會運行。然而,正常的JavaScript呢。
Firebug確認jQuery庫已經加載,當我點擊腳本或Dom ...控制檯甚至會接受並運行我的jQuery代碼,沒有麻煩。
這裏是html ...是的,它是html5,它除了Opera和IE之外,還可以用於所有瀏覽器。
<!DOCTYPE HTML>
<html>
<head>
<title>Produkshunator</title>
<link rel="stylesheet" type="text/css" href="styles/layout.css" />
<link rel="stylesheet" type="text/css" href="styles/skins.css" />
<link rel="stylesheet" type="text/css" href="styles/formlayout.css" />
<link rel="stylesheet" type="text/css" href="styles/index.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="scripts/json2.min.js"></script>
<script type="text/javascript" src="index4.js"></script>
</head>
<body class="vbox flex">
<!-- header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<header class="hbox">
<div class="hbox flex" style="padding-top: 5px;">
<img src="icons/Produkshunator.png" style="height:60px;width:490px;"/>
</div>
<div id="login_status" style="width:150px;"></div>
</header>
<!-- body ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<div class="flex hbox">
<!-- Forms ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<section class="vbox right" style="width:400px; padding:0; overflow: visible;">
<!-- Login Form ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<form class="flex sleek"
name="login"
id="login">
<h2 class="r">Login</h2>
<div>
<label>Email:</label>
<input type="email" name="email"/>
</div>
<div>
<label>Password:</label>
<input type="password" name="password"/>
</div>
<div>
<input type="button" value="Submit" class="form_butt" />
</div>
<p><i id="log_error" class="error"></i></p>
</form>
<!-- Registration Form ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<form class="sleek flex"
name="register"
id="register">
<h2 class="r">Register</h2>
<div>
<label>First Name:</label>
<input type="text" required="flag" name="firstname"/>
</div>
<div>
<label>Last Name:</label>
<input type="text" required="flag" name="lastname"/>
</div>
<div>
<label>Email:</label>
<input type="email" required="flag" name="email"/>
</div>
<div>
<label>Password:</label>
<input type="password" required="flag" name="password"/>
</div>
<div>
<label>Retype Password:</label>
<input type="password" required="flag" name="password2"/>
</div>
<div>
<input type="button" value="Submit" class="form_butt" />
</div>
<p id="reg_error" class="error"></p>
</form>
</section>
</div>
</body>
</html>
有什麼我需要知道的是不是在教程中?
你能所鏈接的頁面或張貼一些HTML?此外,您可能更適合使用Google API版本的jQuery:http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js – mway 2010-10-08 06:43:51
感謝mway ...只是更改了jQuery鏈接並張貼了html。 – cybermotron 2010-10-08 06:53:48
和'index4.js'裏面有什麼? – Reigel 2010-10-08 06:54:59