JQuery测试代码集

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan

JQuery网上搜到的几个教程,编写的测试代码集合.别忘了去下载jquery.js这个文件...

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

<!----------------------menu.html------------------------->

test1_1.html 未使用ajax的切换

test1_2.html 使用ajax的切换

test2.html 简单插入

test3.html 加载

test4.html 交替颜色和鼠标overout变颜色

test5.html window.status

test6.html 图片叠加 || ball.jpg,corner_bl.gif,shadow.gif,shadow180.gif

test7.html DOM外包一层

test8.html 结合php,做按钮点后随即产生 || script.php

<!------------------------test1_1.html----------------------->

<!-- 未使用ajax的切换 -->

<script language="javascript">

function test() {

var external_links = document.getElementById('external_links');

var links = external_links.getElementsByTagName('a');

for (var i=0;i < links.length;i++) {

var link = links.item(i);

link.onclick = function() {

return confirm('You are going to visit: ' + this.href);

};

}

}

</script>

<html>

<head>

<meta http-equiv="Content-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>title</title>

</head>

<body οnlοad="javascript:test();">

<div id="external_links">

<a href="test1_1.html#1">a</a>

<a href="test1_1.html#2">b</a>

<a href="test1_1.html#3">c</a>

<a href="test1_1.html#4">d</a>

</div>

</body>

</html>

<!------------------------ test1_2.html ----------------------->

<!-- 使用ajax的切换 -->

<script type="text/javascript" src=""></script>

<script type="text/javascript" src="jquery-<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.2.1</chsdate>.js"></script>

<script type="text/javascript">

function test() {

$('#external_links a').click(function() {

return confirm('You are going to visit: ' + this.href);

});

}

</script>

<!DOCTYPE html PUBLIC "-//W<chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</chmetcnv>//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-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="" rel="stylesheet" type="text/css" />

<title></title>

</head>

<body οnlοad="javascript:test();">

<div id="external_links">

<a href="test1_2.html#1">e</a>

<a href="test1_2.html#2">f</a>

<a href="test1_2.html#3">g</a>

<a href="test1_2.html#4">h</a>

</div>

</body>

</html>

<!----------------------test2.html------------------------->

<!-- 简单插入 -->

<script type="text/javascript" src="jquery-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.2.1</chsdate>.js"></script>

<script type="text/javascript">

function test() {

$('<p></p>')

.html('Hey World!')

.css('background', 'yellow')

.appendTo("body");

}

</script>

<!DOCTYPE html PUBLIC "-//W<chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</chmetcnv>//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-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="" rel="stylesheet" type="text/css" />

<title></title>

</head>

<body οnlοad="javascript:test();">

</body>

</html>

<!----------------------test3.html------------------------->

<!-- 加载 -->

<script type="text/javascript" src="jquery-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.2.1</chsdate>.js"></script>

<script type="text/javascript">

$(document).ready(function(){

alert("Congratluations!");

});

</script>

<script type="text/javascript" src=""></script>

<!DOCTYPE html PUBLIC "-//W<chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</chmetcnv>//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-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="" rel="stylesheet" type="text/css" />

<title></title>

</head>

<body>

</body>

</html>

<!-----------------------test4.html------------------------>

<!-- 交替颜色和鼠标overout变颜色 -->

<script type="text/javascript" src="jquery-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.2.1</chsdate>.js"></script>

<!DOCTYPE html PUBLIC "-//W<chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</chmetcnv>//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-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="author" content="马永占(MyZ)" />

<meta name="Copyright" content="马永占(MyZ)" />

<meta name="descrīption" content="" />

<meta name="keywords"content="" />

<link rel="icon" href="" type="image/x-icon" />

<link rel="shortcut icon" href="" type="image/x-icon" />

<link href="" rel="stylesheet" type="text/css" />

<title></title>

<script type="text/javascript">

$(document).ready(function(){ //这个就是传说的ready

$(".stripe tr").mouseover(function(){

//如果鼠标移到classstripe的表格的tr上时,执行函数

$(this).addClass("over");}).mouseout(function(){

//给这行添加class值为over,并且当鼠标一出该行时执行函数

$(this).removeClass("over");}) //移除该行的class

$(".stripe tr:even").addClass("alt");

//classstripe的表格的偶数行添加class值为alt

});

</script>

<style>

th {

background:#0066FF;

color:#FFFFFF;

line-height:20px;

height:30px;

}

td {

padding:6px 11px;

border-bottom:1px solid #95bce2;

vertical-align:top;

text-align:center;

}

td * {

padding:6px 11px;

}

tr.alt td {

background:#ecf6fc; /*这行将给所有的tr加上背景色*/

}

tr.over td {

background:#bcd4ec; /*这个将是鼠标高亮行的背景色*/

}

</style>

</head>

<body>

<table class="stripe" width="50%" border="0" cellspacing="0" cellpadding="0">

<!--class="stripe"来标识需要使用该效果的表格-->

<thead>

<tr>

<th>姓名</th>

<th>年龄</th>

<th>QQ</th>

<th>Email</th>

</tr>

</thead>

<tbody>

<tr>

<td>MyZ</td>

<td>20</td>

<td>10000</td>

<td>10000@qq.com</td>

</tr>

<tr>

<td>MyZ</td>

<td>20</td>

<td>10000</td>

<td>10000@qq.com</td>

</tr>

<tr>

<td>MyZ</td>

<td>20</td>

<td>10000</td>

<td>10000@qq.com</td>

</tr>

<tr>

<td>MyZ</td>

<td>20</td>

<td>10000</td>

<td>10000@qq.com</td>

</tr>

<tr>

<td>MyZ</td>

<td>20</td>

<td>10000</td>

<td>10000@qq.com</td>

</tr>

</tbody>

</table>

</body>

</html>

<!----------------------test5.html------------------------->

<!-- window.status -->

<script type="text/javascript" src="jquery-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.2.1</chsdate>.js"></script>

<script type="text/javascript">

$(document).ready(function(){

$('a.affLink').mouseover(function(){window.status="特别的status";return true;})

.mouseout(function(){window.status='Done';return true;});

});

</script>

<!DOCTYPE html PUBLIC "-//W<chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</chmetcnv>//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-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="author" content="马永占(MyZ)" />

<meta name="Copyright" content="马永占(MyZ)" />

<meta name="descrīption" content="" />

<meta name="keywords"content="" />

<link rel="icon" href="" type="image/x-icon" />

<link rel="shortcut icon" href="" type="image/x-icon" />

<link href="" rel="stylesheet" type="text/css" />

<title></title>

<style type="text/css">

<!--

-->

</style>

</head>

<body>

<a href="test5.html#a" class="affLink">aaa</a>

<a href="test5.html#b" class="affLink">bbb</a>

<a href="test5.html#c" class="affLink">ccc</a>

</body>

</html>

<!-----------------------test6.html------------------------>

<!-- 图片叠加 -->

<script type="text/javascript" src="jquery-<chsdate w:st="on" isrocdate="False" islunardate="False" day="30" month="12" year="1899">1.2.1</chsdate>.js"></script>

<script language="JavaScript" type="text/javascript">

$(document).ready(function(){

$("img.dropshadow")

.wrap("<div class='wrap0'><div class='wrap1'><div class='wrap2'>" +

"<div class='wrap3'></div></div></div></div>");

});

</script>

<!DOCTYPE html PUBLIC "-//W<chmetcnv w:st="on" tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C">3C</chmetcnv>//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-Language" content="utf-8" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="author" content="马永占(MyZ)" />

<meta name="Copyright" content="马永占(MyZ)" />

<meta name="descrīption" content="" />

<meta name="keywords"content="" />

<link rel="icon" href="" type="image/x-icon" />

<link rel="shortcut icon" href="" type="image/x-icon" />

<link href="" rel="stylesheet" type="text/css" />

<title></title>

<style type="text/css">

.wrap0, .wrap1, .wrap2, .wrap3 {

display:inline-table;

/* \*/display:block;/**/

}

.wrap0 {

float:left;

background:url(shadow.gif) right bottom no-repeat;

}

.wrap1 {

background:url(shadow180.gif) no-repeat;

}

.wrap2 {

background:url(corner_bl.gif) -18px 100% no-repeat;

}

.wrap3 {

padding:10px 14px 14px 10px;

background:url(corner_tr.gif) 100% -18px no-repeat;

}

body { background: #fff;}

</style>

</head>

<body>

<p>First, the old-school, multiple divs hard coded into the html</p>

<div class="wrap0">

<div class="wrap1">

<div class="wrap2">

<div class="wrap3">

<img

src="ball.jpg"

alt="The object casting a shadow"

/>

</div>

</div>

</div>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值