1.需求

  点击所有的 p 节点, 能够弹出其对应的文本内容

  使第一个 table 隔行变色

  点击 button, 弹出 checkbox 被选中的个数

2.程序

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" SRC="jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function(){
//点击所有的 p 节点, 能够弹出其对应的文本内容
$("p").click(function(){
alert($(this).text());
})
//使第一个 table 隔行变色
$("table:first tr:even").click(function(){
$(this).css("background","#fab");
});
//点击 button, 弹出 checkbox 被选中的个数
$("button").click(function(){
var len=$(":checkbox:checked").length;
alert(len);
})
}) </script>
</head>
<body>
<p>段落1</p>
<p>段落2</p>
<p>段落3</p>
<table>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
</table>
<br>
<hr>
<br>
<table>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
<tr>
<td>第一行</td>
<td>第一行</td>
</tr>
</table> <input type="checkbox" name="test" />
<input type="checkbox" name="test" />
<input type="checkbox" name="test" />
<input type="checkbox" name="test" />
<input type="checkbox" name="test" />
<input type="checkbox" name="test" />
<button>您选中的个数</button>
</body>
</html>

010 使用jquery实现小需求练习-------对应选择器的练习的更多相关文章

  1. 分析一个类似于jquery的小框架

    在网上下了一个类似于jQuery的小框架,分析源码,看看怎么写框架. 选择器Select //用沙箱闭包其整个代码,只有itcast和I暴漏在全局作用域 (function( window , und ...

  2. jquery mobile小案例

    ---恢复内容开始--- [jquery mobile小案例]效果图如下: 首先先创建一个页面主要使用data-role="page"这个指令,我们给它起个id="pag ...

  3. jQuery拼图小游戏

    jQuery拼图小游戏 最后样式 核心代码部分 <script type="text/javascript" > $(function () { $("td& ...

  4. [需求设计]从一个小需求感受Redis的独特魅力

    分享一个简单的小需求应该怎么设计实现以及有关Redis的使用 Redis在实际应用中使用的非常广泛,本篇文章就从一个简单的需求说起,为你讲述一个需求是如何从头到尾开始做的,又是如何一步步完善的.之前写 ...

  5. Kendo UI for jQuery自定义小部件第一弹!不得不看的入门指南

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  6. 从一个小需求感受Redis的独特魅力

    分享一个简单的小需求应该怎么设计实现以及有关Redis的使用 Redis在实际应用中使用的非常广泛,本篇文章就从一个简单的需求说起,为你讲述一个需求是如何从头到尾开始做的,又是如何一步步完善的. 需求 ...

  7. 彻底抛弃PeopleEditor,SharePoint中利用Jquery Chosen创建新的人员选择器

    彻底抛弃PeopleEditor,SharePoint中利用Jquery Chosen创建新的人员选择器 基于SharePoint平台开发时,人员选择器使用频率是非常高的,但是原生的人员选择器使用太麻 ...

  8. JQuery第一天——入门概述与选择器

    一.什么是JQuery 一个流行的js库 核心理念:write less , do more 优势:  轻量级 强大的选择器 出色的 DOM 操作的封装 可靠的事件处理机制 完善的 Ajax 出色的浏 ...

  9. jquery总结01-基本概念和选择器

    dom元素和jquery元素的区别 dom元素支持dom元素自带的属性和方法,jquery元素支持jquery元素自带的属性和方法 dom                  var div = doc ...

随机推荐

  1. Activiti学习——Activiti与Spring集成

    转: Activiti学习——Activiti与Spring集成 与Spring集成 基础准备 目录结构 相关jar包 Activiti的相关jar包 Activiti依赖的相关jar包 Spring ...

  2. python数据分析美国大选项目实战(三)

    项目介绍 项目地址:https://www.kaggle.com/fivethirtyeight/2016-election-polls 包含了2015年11月至2016年11月期间对于2016美国大 ...

  3. 函数和常用模块【day04】: 总结(十二)

  4. 异步消息处理机制Handler

    Android 中的异步消息处理主要由四个部分组成,Message.Handler.MessageQueue 和Looper. 1. Message Message 是在线程之间传递的消息,它可以在内 ...

  5. 设计模式之Mixin模式

    介绍 mixin模式就是一些提供能够被一个或者一组子类简单继承功能的类,意在重用其功能.在面向对象的语言中,我们会通过接口继承的方式来实现功能的复用.但是在javascript中,我们没办法通过接口继 ...

  6. Does Deep Learning Come from the Devil?

    Does Deep Learning Come from the Devil? Deep learning has revolutionized computer vision and natural ...

  7. ActiveMQ Transport Connectors

    一,介绍 ActiveMQ的Transport Connectors 是什么? ActiveMQ是一个消息服务器.作为消息服务器,就会有生产者和消费者来使用它.生产者将消息发送给ActiveMQ,消费 ...

  8. jdk1.8.0_45源码解读——HashMap的实现

    jdk1.8.0_45源码解读——HashMap的实现 一.HashMap概述 HashMap是基于哈希表的Map接口实现的,此实现提供所有可选的映射操作.存储的是<key,value>对 ...

  9. JavaScript编写风格指南 (三)

    七(七):严格模式 // 严格模式应当仅限在函数内部使用,千万不要在全局使用 //不好的写法:全局使用严格模式"user strict"; function doSomething ...

  10. Convert Expression to Reverse Polish Notation

    Given an expression string array, return the Reverse Polish notation of this expression. (remove the ...