Query是一个兼容多浏览器的javascript库,核心理念是write less,do more(写得更少,做得更多),对javascript进行了封装,是的更加便捷的开发,并且在兼容性方面十分优秀。

http://www.php100.com/manual/jquery/

 选择器与筛选器系列

 模态框

a{
text-decoration: none;
color: #428bca;
}
.modal-backdrop{
position: fixed;
top:0;
right:0;
bottom:0;
left:0;
z-index: 1040;
background-color: #000000;
opacity:0.8
}
.modal{
position: fixed;
top:50%;
left:50%;
z-index: 1050;
max-height: 500px;
overflow: auto;
width: 560px;
margin: -250px 0 0 -280px;
background-color: #ffffff;
border: solid 1px #999;
border: 1px solid rgba(0, 0, 0, 0.3);
*border: 1px solid #999;
}
.modal-header{
padding: 9px 15px;
border-bottom: solid 1px #eeeeee;
}
.modal-header .close{
margin-top: 2px;
}
.modal-body{
padding: 10px;
}
.modal-footer{
padding: 14px 15px 15px;
margin-top: 0;
background-color: #f5f5f5;
border-top: solid 1px #dddddd;
-webkit-border-radius: 0 0 6px 6px
-moz-border-radius: 0 0 6px 6px;
border-radius: 0 0 6px 6px;
box-shadow: inset 0 1px 0 #ffffff;
*zoom: 1;
}
.modal-footer .btn{
float: right;
margin-left: 5px;
margin-bottom: 0px;
}
.btn {
display: inline-block;
padding: 6px 12px;
margin-top:0;
font-size: 14px;
font-weight: normal;
line-height: 1.428571429;
text-align: center;
cursor: pointer;
vertical-align: middle;
border: solid 1px transparent;
border-radius: 4px;
}
.btn-sucess{
color: #ffffff;
background-color: #5cb85c;
border:solid 1px #4cae4c;
}
.btn:hover,.bth:focus{
color: #333333;
text-decoration: none;
}
.hide{
display: none;
} /*modal.css*/

  

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模态</title>
<link rel="stylesheet" href="css/modal.css">
<style type="text/css"> </style>
</head>
<body>
<div>
<input type="button" onclick="fadeIn()" value="模态对话框">
</div>
<div id="formTable" class="modal hide">
<form id="form0" method="post" action="">
<div class="modal-header" style="height: 40px;">
<div style="float: left">This is a Modal Heading</div>
<div style="float: right"><a class="close" id="close" onclick="fadeOut()" style="cursor: pointer">x</a></div>
</div>
<div class="modal-body">
<h4>Text in a modal</h4>
<p>You can add some text here.</p>
</div>
<div class="modal-footer">
<a class="btn btn-sucess" onclick="fadeOut()">提交</a>
<a class="btn" data-dismiss="modal" onclick="fadeOut()">关闭</a>
<a class="btn" data-dismiss="modal" onclick="fadeOut()">关闭</a>
</div>
</form>
</div>
<div id="shade" class="modal-backdrop hide"></div>
<script src="jquery-3.1.0.js"></script>
<script>
function fadeIn(){
$("#formTable").removeClass('hide');
$("#shade").removeClass('hide')
}
function fadeOut(){
$("#formTable").addClass('hide');
$("#shade").addClass('hide')
}
</script>
</body>
</html>

 加载

 

.modal-backdrop{
position: fixed;
top:0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
background-color: white;
opacity: 0.8;
}
.modal{
position: fixed;
top:30%;
left:50%;
z-index: 1030;
}
.hide{
display: none;
}

  

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>load</title>
<link rel="stylesheet" href="css/load.css">
</head>
<body>
<div>
<input type="button" value="模态对话框" onclick="fadeIn();">
</div>
<div id="shade" class="modal-backdrop hide">
<div class="modal">
<img src="data:images/loading_32.gif">
</div>
</div>
<script src="jquery-3.1.0.js"></script>
<script type="text/javascript">
function fadeIn(){
$("#shade").removeClass('hide')
}
</script>
</body>
</html> 

  左侧菜单

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>加载</title>
<style type="text/css">
.left{
width: 20%;
height: 500px;
float: left;
background-color: darkslategrey;
}
li{
list-style-type: none;
color: white;
font-size: 20px;
}
.hide{
display: none;
}
.title{
font-size: 25px;
color:red;
} </style>
</head>
<body>
<div class="left">
<ul>
<li class="title" onclick="Func_Menu(this);">家用电器
<ul class="hide">
<li>电视</li>
<li>空调</li>
<li>洗衣机</li>
</ul>
</li>
<li class="title" onclick="Func_Menu(this);">电脑办公
<ul class="hide">
<li>电脑设备</li>
<li>游戏设备</li>
<li>网络设备</li>
</ul>
</li>
<li class="title" onclick="Func_Menu(this);">医药保健
<ul class="hide">
<li>中西药品</li>
<li>营养健康</li>
<li>保健器械</li>
</ul>
</li>
</ul>
</div>
<script src="jquery-3.1.0.js"></script>
<script type="application/javascript">
function Func_Menu(ths){
$(ths).children().removeClass('hide');
$(ths).siblings().children().addClass('hide');
}
</script>
</body>
</html>

  Tab表横向表单

body{
margin: 0 auto;
font-family: Arial;
font-size: 12px;
}
body, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td, figure, div {
margin: 0;
padding: 0;
}
ol,ul,li{
list-style-type: none;
}
.container{
width:1190px;
margin-left: auto;
margin-right: auto;
}
.tab-menu-box1{
border: solid 1px #dddddd;
margin-top:20px;
}
.tab-menu-box1 .menu{
line-height: 33px;
height: 33px;
background-color: #f5f5f5;
}
.tab-menu-box1 .content{
min-height: 100px;
border-top: solid 1px #dddddd;
background-color: white;
}
.tab-menu-box1 .menu ul li{
position: relative;
float: left;
font-size: 14px;
font-family: 'Microsoft Yahei','SimHei';
text-align: center;
font-weight: bold;
border-right: solid 1px #dddddd;
padding: 0 18px;
cursor: pointer;
}
.tab-menu-box1 .menu ul li:hover{
color: #c9033b;
}
.tab-menu-box1 .menu .current{
margin-top:-1px;
color: #c9033b;
background: #ffffff;
height: 33px;
border-top: solid 2px #c9033b;
z-index: 10;
}
.hide{
display: none;
}

  

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>tab</title>
<link rel="stylesheet" href="css/tab.css">
</head>
<body>
<div class="container">
<div class="tab-menu-box1">
<div class="menu">
<ul id="tab-menu-title">
<li class="current" content-to="1">价格趋势</li>
<li content-to="2">市场分布</li>
<li content-to="3">其它</li>
</ul>
</div>
<div id="tab-menu-body" class="content">
<div content="1">content1</div>
<div content="2" class="hide">content2</div>
<div content="3" class="hide">content3</div>
</div>
</div>
</div>
<script src="jquery-3.1.0.js"></script>
<script type="text/javascript">
$(function(){
ChangeTab('#tab-menu-title','#tab-menu-body');
})
function ChangeTab(title,body){
$(title).children().bind('click',function(){
$menu = $(this);
$content = $(body).find('div[content="'+ $(this).attr("content-to") + '"]');
$menu.addClass('current').siblings().removeClass('current');
$content.removeClass('hide').siblings().addClass('hide');
});
}
</script>
</body>
</html>

  拐角

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>拐角</title>
<style type="text/css">
a{
background-color: #ffffff;
border-top: solid 10px red;
border-right: solid 0px;
border-bottom: solid 0px gray;
border-left: solid 20px transparent;
}
.container{
width: 800px;
height: 900px;
background-color: #999999;
margin-left: auto;
margin-right: auto;
}
.top{
height: 20px;
}
.middle{
height: 40px;
background-color: #333333;
margin-left: -18px;
}
h3{
line-height: 40px;
margin-left: 25px;
color: #ffffff;
}
.coner{
border-width: 8px 0px 0px 18px;
border-style: solid;
border-color: #666666 transparent transparent transparent;
margin-left: -18px;
width: 0px;
}
</style>
</head>
<body>
<a></a>
<div class="container">
<div class="top"></div>
<div class="middle">
<h3>汔车之家</h3>
</div>
<div class="left coner"></div>
</div>
</body>
</html>

  弹出确定取消框

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<style type="text/css">
.h{
position: absolute;
margin-top: -55px;
display: none;
}
table td{
height: 25px;
}
.artItLaCorner{
border-width: 8px 8px 8px 8px;
margin:0 0 0 0;
border-style: solid;
border-color: #3498db transparent transparent transparent;
width: 0px;
}
.show{
display: table;
}
</style>
</head>
<body>
<div id="main" style="height: 400px">
<table>
<tr>
<td>第一行</td>
<td>第一行</td>
<td>
<div style="background-color: red">
<div onclick="show(this);">father</div>
<div class="h">
<div style="background-color: #3498db;width: 100px;">
<button>确定</button>
<button onclick="hide(this);">取消</button>
</div>
<div class="artItLaCorner" style="margin-left: 17px;"></div>
</div>
</div>
</td>
</tr>
<tr>
<td>第二行</td>
<td>第二行</td>
<td>
<div style="background-color: red">
<div onclick="show(this);">father</div>
<div class="h">
<div style="background-color: #3498db;width: 100px;">
<button>确定</button>
<button onclick="hide(this);">取消</button>
</div>
<div class="artItLaCorner" style="margin-left: 17px;"></div>
</div>
</div>
</td>
</tr>
<tr>
<td>第三行</td>
<td>第三行</td>
<td>
<div style="background-color: red">
<div onclick="show(this);">father</div>
<div class="h">
<div style="background-color: #3498db;width: 100px;">
<button>确定</button>
<button onclick="hide(this);">取消</button>
</div>
<div class="artItLaCorner" style="margin-left: 17px;"></div>
</div>
</div>
</td>
</tr>
</table>
</div>
<script src="jquery-3.1.0.js"></script>
<script type="text/javascript">
function show(arg){
$(arg).siblings().addClass('show')
}
function hide(arg){
$(arg).parent().parent().removeClass('show')
}
</script>
</body>
</html>

  返回顶部

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>返回顶部</title>
<style>
.container{
height: 2000px;;
}
.back{
position: fixed;
right: 0px;
bottom: 0px;
}
.hide{
display: none;
}
</style>
</head>
<body>
<div class="container"></div>
<div onclick="back_top(this);" class="back hide">返回顶部</div> <script src="jquery-3.1.0.js"></script>
<script type="text/javascript">
function back_top(){
$(window).scrollTop(0)
} // html加载完成,自动执行函数
$(function (){
// 监听鼠标滚轮
$(window).scroll(function(){
var top = $(window).scrollTop();
if(top < 100){
$('.back').addClass('hide')
}else{
$('.back').removeClass('hide')
}
})
}) </script>
</body>
</html>

  全选、取消、反选

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>多选全选反选</title>
</head>
<body>
<div id = "checklist">
<input type="checkbox">足球
<input type="checkbox">蓝球
<input type="checkbox">羽毛球
</div>
<input type="button" value="全选" id="selectAll">
<input type="button" value="取消" id="unselectA">
<input type="button" value="反选" id="reverseAll"> <script src="jquery-3.1.0.js"></script>
<script type="text/javascript">
$(function(){
$("#selectAll").click(function () {
$("#checklist :checkbox").prop("checked",true)
});
$("#unselectA").click(function(){
$("#checklist :checkbox").prop("checked",false)
});
$("#reverseAll").click(function(){
$("#checklist :checkbox").each(function () {
$(this).prop("checked",!$(this).prop("checked"))
})
})
})
</script>
</body>
</html>

  移动面板

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>移动面板</title>
</head>
<body>
//position很重要,没有它,移动会失败
<div style="width: 600px;position: absolute">
<div id="title" style="background-color: black;height: 40px;"></div>
<div style="background-color: #00415e;border: solid 1px red;height: 300px;"></div>
</div>
<script src="jquery-3.1.0.js"></script>
<script type="text/javascript">
$(function(){
$("#title").mouseover(function () {
// 鼠标指针变为move
$(this).css('cursor','move');
}).mousedown(function(e){
// 监听鼠标按下时的x,y坐标
var _event = e||window.event;
var old_x = _event.clientX;
var old_y = _event.clientY; // 其父标签的位置
var parent_left = $(this).parent().offset().left;
var parent_top = $(this).parent().offset().top; // 鼠标移动后的x,y坐标
$(this).bind("mousemove",function (e) {
var _new_event = e||window.event;
var new_x = _new_event.clientX;
var new_y = _new_event.clientY; // 鼠标移动后父标签的真正位置
var x = parent_left + (new_x - old_x);
var y = parent_top + (new_y - old_y); $(this).parent().css("left",x +'px');
$(this).parent().css("top",y +'px');
})
}).mouseup(function(){
$(this).unbind('mousemove')
})
})
</script>
</body>
</html>

  

 滚动菜单 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.left{
width:20%;
height:2000px;
float:left;
position: fixed;
top:10px;
bottom: 0px;
background-color: #fafafa;
}
.right{
width:80%;
float:right;
position: relative;
}
.current{
background-color:gray;
color:white;
}
.r_top{
height:100px;
background-color:red;
}
.c1{
height:1000px;
}
.c2{
height:700px;
}
.c3{
height:300px;
}
</style>
</head>
<body>
<div class="left">
<div class="go-f1">第一章</div>
<div class="go-f2">第二章</div>
<div class="go-f3">第三章</div>
</div>
<div class="right">
<div menu="f1" class="c1">第一章内容</div>
<div menu="f2" class="c2">第二章内容</div>
<div menu="f3" class="c3">第三章内容</div>
</div>
<script src="jquery-3.1.0.js"></script>
<script>
$(function(){
<!--监控滚轮事件-->
$(window).scroll(function(){
<!--滚轮滚动的高度-->
var h_scroll = $(window).scrollTop();
<!--窗口的高度-->
var h_window = $(window).height();
<!--整个文档的高度-->
var h_doc = $(document).height();
<!--已经到了文档的底部-->
if (h_scroll + h_window == h_doc ){
$(".left div:last").addClass("current").siblings().removeClass("current")
}else{
$(".right").children().each(function(){
<!--当前章节相对顶部的高度-->
var off_ths = $(this).offset().top;
<!--当前章节的高度-->
var h_ths = $(this).height();
var total = off_ths + h_ths;
<!--滚动的高度在此章节内-->
if (h_scroll >off_ths && h_scroll < total){
var tmp = '.left .go-' + $(this).attr("menu");
$(tmp).addClass("current").siblings().removeClass("current")
}
})
}
})
})
</script>
</body>
</html>

  ajax跨域

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ajax跨域请求</title>
</head>
<body>
<input type="button" value="跨域" onclick="ajax_fun();">
<!--在此处添加Ajax请求返回的节目清单-->
<div class="container"></div>
<script src="jquery-1.8.2.js"></script>
<script>
function ajax_fun(){
$.ajax({
// 电视节目清单地址
url:'http://www.jxntv.cn/data/jmd-jxtv2.html',
// 请求类型默认GET,可以不写
type:'GET',
// 数据类型,jsonp,跨域数据类型,必填
dataType:'jsonp',
// 此处可以不填
jsonp:'callback',
// jsonp数据以列表形式返回
jsonpCallback:'list',
// 传入返回后的数据,以及包含成功代码的字符串
success:function(data){
$.each(data.data,function(i){
var item = data.data[i];
// 添加p标签,内容为日期,如周日
$(".container").append("<p>"+ item.week +"</p>")
var all_data = item.list
$.each(all_data,function(i){
// 添加a标签及换行标签
$(".container").append("<a href="+ all_data[i].link + ">" + all_data[i].name + " </a>")
$(".container").append("<br>")
}) })
// 错误后的返回数据处理
},error:function(data){
console.log("error..")
}
})
}
</script>
</body>
</html>

  

jquery之实例应用的更多相关文章

  1. jQuery Ajax 实例 ($.ajax、$.post、$.get)

    jQuery Ajax 实例 ($.ajax.$.post.$.get) 转 Jquery在异步提交方面封装的很好,直接用AJAX非常麻烦,Jquery大大简化了我们的操作,不用考虑浏览器的诧异了. ...

  2. JavaScript强化教程——jQuery AJAX 实例

    什么是 AJAX?AJAX = 异步 JavaScript 和 XML(Asynchronous JavaScript and XML).简短地说,在不重载整个网页的情况下,AJAX 通过后台加载数据 ...

  3. jQuery AJAX实例

    <html><head><title>jQuery Ajax 实例演示</title></head><script language= ...

  4. jQuery Ajax 实例 ($.ajax、$.post、$.get)【转载】

    本文转载自:http://jun1986.iteye.com/blog/1399242 Jquery在异步提交方面封装的很好,直接用AJAX非常麻烦,Jquery大大简化了我们的操作,不用考虑浏览器的 ...

  5. jQuery Ajax 实例 ($.ajax、$.post、$.get)转

    Jquery在异步提交方面封装的很好,直接用AJAX非常麻烦,Jquery大大简化了我们的操作,不用考虑浏览器的诧异了. 推荐一篇不错的jQuery Ajax 实例文章,忘记了可以去看看,地址为:ht ...

  6. jQuery 验证实例(shopnc二次开发)

    shopnc 商家用户实现添加用户与前台用户分离, jQuery 验证实例 equalTo:等于 <div id="saleRefund" show_id="1&q ...

  7. 一个简单的jQuery插件开发实例

    两年前写的一个简单的jQuery插件开发实例,还是可以看看的: <script type="text/javascript" src="jquery-1.7.2.m ...

  8. 锋利的jQuery幻灯片实例

    //锋利的jQuery幻灯片实例 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  9. jQuery插件实例五:手风琴效果[动画效果可配置版]

    昨天写了个jQuery插件实例四:手风琴效果[无动画版]那个是没有动画效果的,且可配置性不高,本篇为有动画效果.对于一些数据做了动态的计算,以实现自适应. 欢迎大家入群相互交流,学习,新群初建,欢迎各 ...

  10. jQuery UI 实例 – 切换(Toggle)

    toggle()函数用于为每个匹配元素的click事件绑定轮流的处理函数. toggle()是一个特殊的事件函数,用于为匹配元素的click事件绑定多个事件处理函数.每次触发click事件时,togg ...

随机推荐

  1. Spring Security 从配置入门 学习讲解。万恶之源------------web.xml

    这段时间,工作闲了下来,接触了Spring Security,对于我一个基础很差的人来说,无疑是个挑战啊. 经过一段时间的摸索,终于有了点眉目,在这里,要特别感谢http://blog.csdn.ne ...

  2. 用tcpdump分析tcp三次握手,四次挥手

    1.tcpdump 简介 tcpdump是一个对网络上的数据包进行截获的包分析工具,一般linux系统以命令的形式使用 2.tcp三次握手 建立一个tcp连接会发生下面三个过程: 1.服务器必须准备好 ...

  3. 头疼--windows之安装meteor.js

    如果你的电脑是window,这篇文章会的对你有些帮助. 进入meteor官网下载的meteor for windows安装包老是安装失败而且很慢,很慢,经过一番研究之下,终于安装成功了,特此来分享下经 ...

  4. Frame动画实战

    Android动画分为Tween动画和Frame动画,Tween动画主要包括图片的放大缩小.旋转.透明度变化.移动等等操作:Frame动画则简单得多了,就是把一张张的图片连续播放产生动画效果. 本节主 ...

  5. canvas转盘抽奖

    1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" ...

  6. 主要由顶点容器构成的平面图形类(Shape)——(第一次作业Draw类定义升级)

    // https://github.com/orocos/orocos_kinematics_dynamics/blob/master/orocos_kdl/src/frames.hpp // Vec ...

  7. Doherty Threshold

    Prior to the publication of the IBM technical paper behind what commonly known today as the Doherty ...

  8. 适配布局-ios

    // 系统的约束代码 @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIView *superVi ...

  9. java生成二维码(需导入第三方ZXing.jar包)

    //这个类是用来解析,通过图片解析该图片的网页链接是什么 package util; import java.awt.Graphics2D;import java.awt.geom.AffineTra ...

  10. Eclipse快捷键大全

    Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加)Ctrl+Alt+↑ 复制当前行到上一行(复制增加)Alt+↓ 当 ...