我当时正在等待警告已准备就绪,但由于一些奇怪的原因,这种情况真的没有发生。可能出了什么问题? 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>
答案 0 :(得分:9)
您需要将这些脚本分成两个不同的块:
<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>
答案 1 :(得分:3)
脚本需要分开。
<script type="javascript" src="js/jquery-2.1.1.min.js"></script>
<script>
$(document).ready(function(){
alert("Doc Ready"); // :)
});
</script>