JQuery测试代码集

系统 1954 0
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 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 onload="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 onload="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 onload="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(){

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

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

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

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

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

// class stripe 的表格的偶数行添加 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>

分享到:
评论

JQuery测试代码集


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论