我試圖加載我的jQuery腳本,但是當我加載頁面時,警告消息不會出現。文件main.js保存在我有index.html頁面的同一個文件夾中,所以我用它來調用頁面,但沒有任何事情發生,我沒有看到任何錯誤。jquery警告沒有出現
<script type="text/javascript" src="main.js"></script>
這裏我的html:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
</head>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. In veniam doloremque voluptate debitis quaerat ipsum, officia, ad exercitationem placeat quasi nobis enim itaque. Adipisci ullam magnam sequi eum maiores, quia!</p>
<script type="text/javascript" src="main.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
的jQuery:
(function($) {
$(document).ready(function(){
alert('This shit is not working');
});
})(jQuery);
你需要移動<腳本類型= 「文/ JavaScript的」 SRC = 「main.js」>後 –
@Azeez Kallayi你就是對的 –