jquery中filter(fn)的使用研究
jquery中filter(fn)给出的官方说明是:
HTML 代码:
jQuery 代码:
结果:
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JqeryClick.aspx.cs" Inherits="AJAXEnabledWebApplication1.JqeryClick" %>
- <!DOCTYPE html PUBLIC "-//W3C//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 runat="server">
- <title>无标题页</title>
- <mce:script src="jquery-1.3.2.min.js" mce_src="jquery-1.3.2.min.js" type="text/javascript"></mce:script>
- <mce:script type="text/javascript"><!--
- $(function(){
- $("#btn").click(function(){
- //在ViewDiv中显示二种下拉列表当前被选中的内容。显示出来的是value值。
- $("#ViewDiv").html($("#ddlSel").val() + "-----" + $("#Select1").val());
- //这里有一点我要说明的事,我使用的.aspx文件,这种文件会在<form>内自己生成自己的几个<div>,它不是我要取的
- //所以在这里我加了一个大的div来取我们所要的。
- //这里用filter(fn)来过滤掉里面包含ol的项
- $("#all").children("div").filter(function(index) {
- return $("ol", this).size() == 0;
- }).each(function(index){
- //这里显示出这些div的内容。请注意,在这里我们用
- //$("div",this).html()这种方法
- alert($("#"+this.id+"").html());
- });
- })
- })
- // --></mce:script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div id="all">
- <div id="one">
- <asp:DropDownList ID="ddlSel" runat="server">
- <asp:ListItem Value="1">第一项</asp:ListItem>
- <asp:ListItem Value="2">第二项</asp:ListItem>
- </asp:DropDownList>
- <select id="Select1">
- <option value="3">第三项</option>
- <option value="4">第四项</option>
- </select>
- <input id="btn" type="button" value="显示信息" /></div>
- <div id="ViewDiv"></div>
- <div id="2"><ol><li>Hello</li></ol></div><div id="1">How are you?</div>
- </div>
- </form>
- </body>
- </html>
jquery中filter(fn)的使用研究的更多相关文章
- Jquery中$与$.fn的差别
当今web开发往往离不开Jquery的使用,Jquery以其简洁的使用方式.良好的浏览器兼容性赢得了软件研发同行的青睐,作为当中的一员,自然也不例外,虽然刚開始时非常排斥Jquery,今天我谈一下对J ...
- jquery中onclick="fn"中$(this)所代表的对象
jquery中onclick="fn"中$(this)所代表的对象 js方法 function qiehuan(){ var src = $(this).attr("da ...
- jquery中的$.fn的用法
JQuery里的原型prototype分析 http://www.nowamagic.net/librarys/veda/detail/653 jquery中的$.fn的用法 ...
- Jquery中$与$.fn的区别
Jquery中$与$.fn的区别 当今web开发往往离不开Jquery的使用,Jquery以其简洁的使用方式.良好的浏览器兼容性赢得了软件研发同行的青睐,作为其中的一员,自然也不例外,尽管刚开始时很排 ...
- jquery中filter的用法
一.filter的参数类型可分为两种 1.传递选择器 $('a').filter('.external') 2.传递过滤函数 $('a').filter(function(index) { ...
- 【jQuery】【转】jQuery中filter()和find()的区别
Precondition: 现在有一个页面,里面HTML代码为: <div class="css"> <p class="rain">测 ...
- jQuery中filter(),not(),split()的用法
filter(),not(): <script type="text/javascript"> $(document).ready(function() { //输出 ...
- jquery中的 $.fn $.fx
$.fn是指 jquery的命名空间,加上fn上的方法及属性,会对jquery实例每一个有效. 如扩展$.fn.abc() 那么你可以这样子:$("#div").abc(); 常使 ...
- jquery中filter()和find()函数区别
通常把这两个函数,filter()函数和find()函数称为筛选器. 下面的例子分别使用filter函数和find函数对一组列表进行筛选操作. 一组列表: <li>1</li> ...
随机推荐
- CentOS查看内核版本、系统版本、系统位数
http://blog.51cto.com/ultrasql/1640435
- MySQL服务器 IO 100%的案例分析
[问题] 有台MySQL 5.6.21的数据库实例以写入为主,IO %util接近100% 写入IOPS很高 [分析过程] 1.通过iotop工具可以看到当前IO消耗最高的mysql线程 2.查看线程 ...
- (一)预定义宏、__func__、_Pragma、变长参数宏定义以及__VA_ARGS__
作为第一篇,首先要说一下C++11与C99的兼容性. C++11将 对以下这些C99特性的支持 都纳入新标准中: 1) C99中的预定义宏 2) __func__预定义标识符 3) _Pragma操作 ...
- #pragma region、{}
定义一个region,这个region内部的代码你可以把它折叠起来是用于组织代码的,没有其他特别重要的意义. 而{}定义了作用域 { int a = 0; } { int a = 0; }
- 通过Nuget添加Mvvmlight框架发生错误
IDE:Visual Studio 2013 场景:通过Nuget添加Mvvmlight框架 具体错误: 解决办法:删除Nuget,然后添加新版本的Nuget Package Manager 具体操作 ...
- 深入理解RESTful Web Services
RESTful的软件架构已经多火不用多说,和MVC架构一样,很多网站服务(Web Services)都遵循RESTful设计模式,那么到底什么是RESTful Web Services呢?设计一个RE ...
- HDU 4685 Prince and Princess 二分图匹配+tarjan
Prince and Princess 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4685 Description There are n pri ...
- Linux性能监控分析命令(三)—iostat命令介绍
性能监控分析的命令包括如下: 1.vmstat 2.sar 3.iostat 4.top 5.free 6.uptime 7.netstat 8.ps 9.strace 10.lsof 命令介绍: i ...
- git pull的时候出错: Git Couldn't reserve space for cygwin's heap
具体: 1. 运行CMD,以管理员身份打开 2. 运行:rebase.exe -b 0x50000000 msys-1.0.dll 再次git pull的时候,不再报错 转自:http://doc.o ...
- Python threads synchronization: Locks, RLocks, Semaphores, Conditions, Events and Queues(Forwarding)
This article describes the Python threading synchronization mechanisms in details. We are going to s ...