jQuery 基本实现功能模板
下面是列出了基本功能的实现
<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){ <!--选择器-->
$("p").click(function(){
$(this).hide();
});
<!--事件-->
$("#button1").click(function(){
window.alert("单击事件");
})
$("#button2").dblclick(function(){
window.alert("双击事件");
})
$("#button3").mouseenter(function(){
window.alert("鼠标移动事件");
})
<!--隐藏和显示-->
$("#hide").click(function(){
$(".showtext").hide();
});
$("#show").click(function(){
$(".showtext").show();
});
$("#toggle").click(function(){
$(".showtext").toggle();
});
<!--动画-->
$("#animate").click(function(){
$(".animate").animate({
left:'250px',
opacity:'0.5',
height:'150px',
width:'150px'
});
}); <!--操作DOM对象-->
$("#btn1").click(function(){
alert("Text: " + $("#test").text());
});
$("#btn2").click(function(){
alert("HTML: " + $("#test").html());
}); $("#btn3").click(function(){
alert("Value: " + $("#testvalue").val());
}); $("#btn4").click(function(){
alert("id->"+ $("#w3s").attr("id") + "href->" + $("#w3s").attr("href"));
}); $("#btn5").click(function(){
alert($("#btn5text").text("<B>你好啊</B>"));
}); <!--添加元素-->
$("#btnadd1").click(function(){
$(".btnadd1").append("<p>添加的一个元素</p>");
}); <!--操作 CSS-->
$("#btnaddcss").click(function(){
$(".btncss").addClass("important");
}); $("#btndelcss").click(function(){
$(".btncss").removeClass("important");
}); $("#btntoggleClass").click(function(){
$(".btncss").toggleClass("important");
}); $("#btntsetClass").click(function(){
$(".btncss").css({"background-color":"yellow","font-size":"200%"});
}); });
</script>
<style type="text/css">
.important
{
font-weight:bold;
font-size:xx-large;
}
.blue
{
color:blue;
}
</style>
<title>Jquery用法速用表</title>
</head>
<body>
<div style="background:#abcdef">
选择器
</div><hr>
<p>如果你点我,我就会消失</p>
<p>如果你点我,我就会消失</p>
<p>如果你点我,我就会消失</p> <div style="background:#abcdef">
事件
</div><hr>
<input type="button" id="button1" value="单击事件"/>
<input type="button" id="button2" value="双击事件"/>
<input type="button" id="button3" value="鼠标移动事件"/> <div style="background:#abcdef">
隐藏和显示
</div><hr>
<p class="showtext">如果你点击“隐藏” 按钮,我将会消失。</p>
<button id="hide">隐藏</button>
<button id="show">显示</button>
<button id="toggle">显示或者隐藏</button> <div style="background:#abcdef">
动画
</div><hr>
<div class="animate"style="background:#98bf21;height:100px;width:100px;position:absolute;">
</div> <button id="animate">开始动画</button><br>
<br><br><br><br><br><br><br><br><br> <div style="background:#abcdef">
操作DOM对象
</div><hr>
显示文本:<p id="test">This is some <b>bold</b> text in a paragraph.</p>
<button id="btn1">显示文本</button>
<button id="btn2">显示HTML</button><br><hr>
显示value:<p>Name: <input type="text" id="testvalue" value="my name is sun"></p>
<button id="btn3">显示value</button><br>
获得任意属性的值:<p><a href="http://www.yinghy.com" id="w3s">樱花雨</a></p>
<button id="btn4">获得任意属性的值</button><br><hr> 设置文本的属性:<p id="btn5text">This is a paragraph.</p>
<button id="btn5">设置文本属性</button><br><hr> <div style="background:#abcdef">
添加元素
</div><hr> <p class="btnadd1">This is a paragraph.</p>
<button id="btnadd1">添加文本</button> <div style="background:#abcdef">
操作 CSS
</div><hr> <p class="btncss">This is a paragraph.</p>
<button id="btnaddcss">添加 CSS样式</button>
<button id="btndelcss">删除 CSS样式</button>
<button id="btntoggleClass">自动添加和删除 CSS样式</button>
<button id="btntsetClass">具体设置单个 CSS样式</button> </body>
</html>
jQuery 基本实现功能模板的更多相关文章
- 基于jQuery带备忘录功能的日期选择器
今天给大家分享一款基于jQuery带备忘录功能的日期选择器.这款日期控制带有备记忘录功能.有备忘录的日期有一个圆圈,单击圆圈显示备忘录.该实例适用浏览器:360.FireFox.Chrome.Safa ...
- 自己使用Jquery封装各种功能分享
自己使用Jquery封装各种功能分享: 左右滚动图片 瀑布流 流动显示列表 广告切换 头像切换And广告切换 获取搜索引擎的来源关键字 上面列表中展示的功能都是使用jquery进行封装实现的,希望大家 ...
- jquery实现菜单功能(单击展开或者关闭)-一般应用于后台
<!doctype html> <html> <head> <meta charset="gb2312"> <title> ...
- js、jquery实现模糊搜索功能
模糊搜索功能在工作中应用广泛,并且很实用,自己写了一个方法,以后用到的时候可以直接拿来用了! 实现的搜索功能: 1. 可以匹配输入的字符串找出列表中匹配的项,列表框的高度跟随搜索出的列表项的多少改变 ...
- 超炫jQuery测试答题功能
推荐一款超炫jQuery测试答题功能插件 实例代码 <body> <div class="container" id="main"> & ...
- count_if 功能模板
count_if 功能模板 template <class InputIterator, class UnaryPredicate> typename iterator_traits< ...
- jquery 插件和后台模板搜集
弹框 alert confirmhttp://www.jq22.com/jquery-info2607 jQuery表格排序筛选插件http://www.jq22.com/jquery-info880 ...
- jQuery mobile 核心功能
原文地址:http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/about/features.html 基于 jQuery 核心,使用和jQue ...
- Jquery回到顶部功能
问题描述: 在网页中,我们经常会由于网页内容过长,而需要在浏览网页时有一个快速回到网页顶部的功能,在浏览网页内容离顶部有一段距离时,出现快速回到网页顶部的工具,从而能使我们的网页更人性化. 问题的产生 ...
随机推荐
- 142 Linked List Cycle II(如果链表有环,找到入口结点Medium)
题目意思:如果有环,返回入口结点 思路:先判断有没环,再计算环的结点数,然后p1指向头,p2往后移结点次数,p1.p2相遇为入口结点 ps:还是利用指针间距这个思路 /** * Definition ...
- python的bind函数
# -*- coding:utf-8 -*- class Functor(object): def __init__(self, func, index=0, *args, **kwargs): se ...
- Oracle的Net Configuration Assistant 配置
在进行团队开发的时候,一般团队的每一个人只需要安装一个客户端即可,没有必要安装一个Oracle 数据库服务器,而数据库服务器是属于共享的,此时,我们就需要配置客户端.客户端的配置可以有以下两种方式:第 ...
- Java 的性能优化
jvm 中的方法区: 永久区---存的类的信息.方法.常量 .静态变量 1.Java的性能优化 1.减少gc的压力,优先级比较低的线程,他是一个守护线程 回收我们的堆内存. 2.尽量的避免我们的new ...
- spring restful 中文乱码问题
进行如下配置: @RequestMapping( value="/zzs/xgm", produces="application/json;charset=utf-8&q ...
- Red Hat TimesTen安装记录
1:内核参数修改 # vi /etc/sysctl.conf kernel.sem= #sysctl –p 备注:此安装过程为测试环境,具体参数修改要参考TimesTen官方文档. 2:创建用户及组信 ...
- mobile plugin
http://fronteed.com/iCheck/ http://spritely.net/documentation/ http://www.mobilexweb.com/blog/mobile ...
- cf C. Hacking Cypher
http://codeforces.com/contest/490/problem/C 题意:把一个很大的数分成两部分,前一部分可以被a整除,后一部分可以被b整除,如果存在输出这两部分,两部分都不能含 ...
- SCALA常规练习C
package com.hengheng.scala abstract class Animal { def walk(speed : Int) def breathe() = { println(& ...
- Android 介绍spydroid每个包的大体功能
看了接近一周的spydroid源代码,对spydroid这个开源项目有了一定的认识.也许有些理解不一定正确,给后来者一点启示.也是自己对rtsp协议,rtp协议的总结. 在windows下,如果安装了 ...