自己写了个jquery的例子,但总是说有问题存在内容:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text ml; charset=gb2312" />
<title>无标题文档</title><style type="text/css">
.special
{
font-weight:bold;
color:#FF0000;
}
$("#ljb").CSS({
color:#00FF00)};
</style><script type="text/javascript">
function a(){
$("div").addclass("special");
}
</script>
</head><body onload="a()">
<div id="div1"> aaaa</div>
<div id="sd">
bbbbbbb
</div>
</body>
</html>
不知道这有什么问题,刚学jquery,各位多给点意见,在自己写的时候就和写script一样吧,没有什么特别的东西吧
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text ml; charset=gb2312" />
<title>无标题文档</title><style type="text/css">
.special
{
font-weight:bold;
color:#FF0000;
}
$("#ljb").CSS({
color:#00FF00)};
</style><script type="text/javascript">
function a(){
$("div").addclass("special");
}
</script>
</head><body onload="a()">
<div id="div1"> aaaa</div>
<div id="sd">
bbbbbbb
</div>
</body>
</html>
不知道这有什么问题,刚学jquery,各位多给点意见,在自己写的时候就和写script一样吧,没有什么特别的东西吧
$("div").addClass("special");//注意大小写哦
}orfunction a(){
$("div").each(function () {
$(this).addClass("special");//注意大小写哦
});
}
引用方法:<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs
/jquery/1.4.0/jquery.min.js"></script>
</head>
或者:<head>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
</head>
v1.4 160k
其实你下载一个就知道了~
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title><style type="text/css">
.special
{
font-weight:bold;
color:red;
}
</style><script type="text/javascript" src="../JQuery/jquery-1.4.2.min.js">
$().ready(
function(){
$("div").addClass("special");
}
);
</script>
</head><body> <div id="div1"> aaa</div>
<div >
bbbb
</div>
</body>
</html>
{ %> <script type="text/javascript" src="../js/jquery-1.4.2-vsdoc.js"></script> <%} %>
建议你先看看相关js的基础和jquery的示例、文档、书籍等
<script type="text/javascript" src="../JQuery/jquery-1.4.2.min.js">
1、不能在导入js文件的script标签中写代码
2、$().ready没有这种写法
$().ready(
function(){
$("div").addClass("special");
}
);
</script>修改后
<script type="text/javascript" src="../JQuery/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
//ready 函数
$(document).ready(function () {
$("div").addClass("special");
}); //ready简写
$(function () {
$("div").addClass("special");
});
</script>