[英]jquery not working on my html page. I am not getting alert onLoad of the page as expected
我期望會彈出准備好警報的文檔,由於某種奇怪的原因,這確實沒有發生。 可能出什么問題了? jQuery庫的位置在js目錄中。 我在所有瀏覽器上嘗試過,但無法正常工作。 順便說一句,我對jQuery非常陌生,不知道如何使其工作。
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="javascript" src="js/jquery-2.1.1.min.js">
$(document).ready(function(){
alert("Doc Ready"); // I was expecting the alert to work which is not happening.
}
);
</script>
<style type="text/css">
#topbar {
height: 40px;
width: 98%;
background-color: #062f9e;
border-style: solid;
border-width: 5px;
border-color: goldenrod;
text-align: center;
font-family: fantasy;
font-style: normal;
font-size: 24px;
color: darkkhaki;
font-weight: bold;
}
#contentPane {
margin-top : 50px;
left: 0;
right: 0;
height: 100%;
background-color: sandybrown;
border-color: darkslategray;
border: thick;
}
body {
width: 100%;
height: 100%;
background-color: darkgrey;
}
.image{
height: auto;
width: auto;
float: left;
border-style: solid;
border-color: ghostwhite;
border-width: 10px;
}
</style>
</head>
<body>
<div id="topbar">AGNI SHIKHA</div>
<div id="contentPane">
<img id="agnishikaImg" class="image" src="res/agnishikha.jpeg" alt="Agnishikha Image">
</div>
<div style="clear: both;"></div>
</body>
</html>
您需要將這些腳本分成兩個不同的塊:
<script src="js/jquery-2.1.1.min.js"></script>
<script>
$(document).ready(function () {
alert("Doc Ready"); // I was expecting the alert to work which is not happening.
});
</script>
腳本需要分開。
<script type="javascript" src="js/jquery-2.1.1.min.js"></script>
<script>
$(document).ready(function(){
alert("Doc Ready"); // :)
});
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.