下面是列出了基本功能的实现

<!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 基本实现功能模板的更多相关文章

  1. 基于jQuery带备忘录功能的日期选择器

    今天给大家分享一款基于jQuery带备忘录功能的日期选择器.这款日期控制带有备记忘录功能.有备忘录的日期有一个圆圈,单击圆圈显示备忘录.该实例适用浏览器:360.FireFox.Chrome.Safa ...

  2. 自己使用Jquery封装各种功能分享

    自己使用Jquery封装各种功能分享: 左右滚动图片 瀑布流 流动显示列表 广告切换 头像切换And广告切换 获取搜索引擎的来源关键字 上面列表中展示的功能都是使用jquery进行封装实现的,希望大家 ...

  3. jquery实现菜单功能(单击展开或者关闭)-一般应用于后台

    <!doctype html> <html> <head> <meta charset="gb2312"> <title> ...

  4. js、jquery实现模糊搜索功能

    模糊搜索功能在工作中应用广泛,并且很实用,自己写了一个方法,以后用到的时候可以直接拿来用了! 实现的搜索功能: 1. 可以匹配输入的字符串找出列表中匹配的项,列表框的高度跟随搜索出的列表项的多少改变 ...

  5. 超炫jQuery测试答题功能

    推荐一款超炫jQuery测试答题功能插件 实例代码 <body> <div class="container" id="main"> & ...

  6. count_if 功能模板

    count_if 功能模板 template <class InputIterator, class UnaryPredicate> typename iterator_traits< ...

  7. jquery 插件和后台模板搜集

    弹框 alert confirmhttp://www.jq22.com/jquery-info2607 jQuery表格排序筛选插件http://www.jq22.com/jquery-info880 ...

  8. jQuery mobile 核心功能

    原文地址:http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/about/features.html 基于 jQuery 核心,使用和jQue ...

  9. Jquery回到顶部功能

    问题描述: 在网页中,我们经常会由于网页内容过长,而需要在浏览网页时有一个快速回到网页顶部的功能,在浏览网页内容离顶部有一段距离时,出现快速回到网页顶部的工具,从而能使我们的网页更人性化. 问题的产生 ...

随机推荐

  1. extjs中rowEditing动态编辑

    我们在使用Grid的rowEditing插件时希望能够根据自己的业务需求能够动态的实现那一列是用户可以编辑的,那一列用户不可编辑,下面给出一个方案能够实现rowEditing的动态编辑功能. 之前我通 ...

  2. sublime3 插件pylinter的安装

    1.首先sublime需要安装package control,之后安装pylinter插件,并进行简单的属性配置(网上教程很多,略) 2.之后是pylint_path的配置,我参照网上的配置失败,su ...

  3. 如何去除 ckeditor 上传图片后在原码中留下的 style="width: 100%;height:100px"之类的代码呢?

    ckeditor编辑器在上传图片的时候,会神奇的加上一段诡异的代码: 这导致上传的小图也是被拉伸到100%,我根本就没有定义它,找来找去也找不到element.style,原来这是在system.cs ...

  4. Python Django开始

    1.创建工程 C:\procedure\projects>django-admin startproject mysite 2.同步数据库 C:\procedure\projects\mysit ...

  5. SCJP_104——题目分析(2)

    3. public class IfTest{ public static void main(String args[]){ int x=3; int y=1; if(x=y) System.out ...

  6. c++内存管理错误记录

    extern "C" _CRTIMP int __cdecl _CrtIsValidHeapPointer( const void * pUserData ){ if (!pUse ...

  7. a标签的 target 使用

    <a target="_blank" href="www.baidu.com" onclick="return test()"> ...

  8. DIV+CSS两种盒子模型

    盒子模型有两种,分别是 IE 盒子模型和标准 W3C 盒子模型.他们对盒子模型的解释各不相同, 先来看看我们熟悉的标准盒子模型: 从上图可以看到标准 W3C 盒子模型的范围包括 margin.bord ...

  9. get set

    关于C# get set的文章很多,但是笔者的这篇文章有它的特别之处,笔者用简单的语言把c# get set讲述的十分明了. C# get set释一:属性的访问器包含与获取(读取或计算)或设置(写) ...

  10. nutch fetcher.server.delay

    1 配置因素 <property>  <name>fetcher.server.delay</name>  <value>0.0</value&g ...