2011-09-22 23 views
0

當我在html文檔中包含jQuery時,此代碼完美地工作正常;但是,如果將它放到外部JavaScript文件中,它會完全停止工作。我在引用外部js文件之前引用了jQuery庫,所以我不確定問題是什麼。我已經是jQuery的初學者了。使用外部.js文件和使用谷歌加載器有問題?

<!DOCTYPE html> 
<html> 
<head> 
<title>HTML 5 Stuff</title> 
<script src="http://www.google.com/jsapi"></script> 
<script type="text/javascript" src="/html5.js"></script> 
<head> 
<body> 
<figure> 
    <img src="http://www.yalibnan.com/wp-content/uploads/2011/02/steve-jobs1.jpg" alt="Steve Jobs" /> 
    <figcaption> 
     <p>Steve Jobs before giving up his title as CEO of Apple Inc.</p> 
    </figcaption> 
</figure> 
<section> 
<ul id="edit" contenteditable="true"> 
<li>List item one</li> 
</ul> 
</section> 
</body> 
</html> 

和JavaScript:

google.load("jquery", "1.3.2"); 
google.setOnLoadCallback(function() { 
    $(function($) { 
     var edit = document.getElementById('edit'); 
     $(edit).blur(function(){ 
      localStorage.setItem('todoData', this.innerHTML); 
      }); 

     if(localStorage.getItem('todoData')){ 
      edit.innerHTML = localStorage.getItem('todoData'); 
      } 
    }); 
}); 
+2

HTML5是否需要'

相關問題