jQuery addClass()方法无效 但放在$(function(){....})里面和 将代码放在文档末尾又有效 请问问什么?
<%@pagelanguage="java"pageEncoding="GB2312"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01T...
<%@ page language="java" pageEncoding="GB2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>123</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css">
.drag{width:100px;height:200px;background:red}
</style>
<script type="text/javascript" src="jquery.js"></script>
</head>
<script type="text/javascript">
$("div").addClass("drag");
</script>
<body>
<div></div>
</body>
</html>
调用下面这段代码时 直接$("div").say(); 就可以不用放在$(function(){...})里面 也不用放在文档末尾 为什么?
(function($){
$.fn.extend({
say:function(){
alert("----");
}
});
})(jQuery); 展开
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>123</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css">
.drag{width:100px;height:200px;background:red}
</style>
<script type="text/javascript" src="jquery.js"></script>
</head>
<script type="text/javascript">
$("div").addClass("drag");
</script>
<body>
<div></div>
</body>
</html>
调用下面这段代码时 直接$("div").say(); 就可以不用放在$(function(){...})里面 也不用放在文档末尾 为什么?
(function($){
$.fn.extend({
say:function(){
alert("----");
}
});
})(jQuery); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询