我正在测试这个jQuery代码,但它没有运行.我打开控制台(F12),在粘贴测试代码后,它完美地编译了它.虽然我删除了src ="http://code.jquery.com/jquery-latest.min.js"并从$(文件).ready(function(){得到警报{然后警报工作,但我得到了来自控制台的消息:"未捕获的ReferenceError:$未定义".我想知道为什么会这样?请问有什么帮助吗?
这是我的测试代码:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js">
$(document).ready(function(){
alert('Hi!');
$("#content").append('<div class=\'toolbarBox toolbarHead\' style=\'background-color: #F8F8F8;border: 1px solid #CCCCCC;margin-bottom: 10px;padding: 5px 0;border-radius: 3px;-moz-border-radius: 3px;-webkit-border-radius: 3px;-o-border-radius: 3px;position: relative;\'><div class=\'pageTitle\'><h3 style = \'font-size: 1.6em;font-weight: normal;line-height: 52px;text-shadow: 0 1px 0 #fff;\'><span id=\'current_obj\' style=\'font-weight: normal;\'><span class=\'breadcrumb item-0\'>My Affiliates<img alt=\'>\' style=\'margin-right:5px\' src=\'../img/admin/separator_breadcrumb.png\'></span><span class=\'breadcrumb item-1\'>Affiliates</span></span></h3></div></div>');
$("#content").append("<iframe style=\'width: 100%;height: 100%;\' src=\'http://www.myaffiliates.gr/\'></iframe>");
});
Run Code Online (Sandbox Code Playgroud)
我正在学习jquery是如何工作的,到目前为止它还是很好,但是我被困在了$(this)对象上.以下是我不太了解的代码部分.
$(".photos").on("mouseenter", "li", function(){
$(this).closest(".photos").find("span").slideToggle();
});
Run Code Online (Sandbox Code Playgroud)
该$(this)指的是与类照片($("照片"))的元素或李(一个或多个),这是在内部使用类照片中的元素?
我正在研究我的JavaScript技能,并编写了一小段代码:
var Intel = ["a", "v", "f", "c", "s"];
if (Intel && Intel.constructor == Array) {
alert('correct');
} else {
alert("false");
}
alert(Intel.length);
function showThemAll() {
// this function will alert every single data of the table
for (var i = 0; i <= Intel.length; i++) {
//alert of the data
alert(Intel[i]);
}
}
showThemAll();
Run Code Online (Sandbox Code Playgroud)
我不明白为什么,正确的结果,我得到一个未定义的警报.
你能帮帮我吗?