我在Yahoo!的测试站点上设置了一个简单的jquery脚本。域站点。它应该显示文本文件中的随机字符串,并将其转储到具有适当类的div中。
我似乎无法弄清楚我做错了什么。
http://hennesseydesign.com/os/os.html
来源:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Oblique Strategies</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type=“text/javascript”>
jQuery(document).ready(function($) {
$.get('quotes.txt', function(data) {
var quotes = data.split("\@");
var idx = Math.floor(quotes.length * Math.random());
$('.quotes').html(quotes[idx]);
});
});
</script>
<style type="text/css">
.quotes {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 14px;
font-style: italic;
color: #000000;
background-color:#eee;
text-decoration: none;
height:40px;
text-align: right;
overflow: hidden;
width: 600px;
display:table-cell;
vertical-align:middle;
}
</style>
</head>
<body>
<div class="quotes"></div>
</body>
</html>
源文本文件在这里:http://www.hennesseydesign.com/os/quotes.txt
我觉得这是服务器端的问题。我将不胜感激任何帮助!
最佳答案
您在“
元素的type属性中使用了错误的引号"
而不是script
,因此不会处理script
元素的内容
<script type="text/javascript">
jQuery(document).ready(function($) {
$.get('quotes.txt', function(data) {
var quotes = data.split("\@");
var idx = Math.floor(quotes.length * Math.random());
$('.quotes').html(quotes[idx]);
});
});
</script>