jQuery - slice( start, [end] ) Method
Description
The slice( start, end ) method selects a subset of the matched elements.
Syntax
Here is the simple syntax to use this method −
selector.slice( start, end )
Parameters
Here is the description of all the parameters used by this method −
start − Where to start the subset. The first element is at zero. Can be negative to start from the end of the selection.
end − Where to end the subset excluding end element. If unspecified, ends at the end of the selection.
Example
Following is a simple example a simple showing the usage of this method −
<html><head><title>The jQuery Example</title><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><script type="text/javascript" language="javascript">$(document).ready(function() {$("li").slice(2, 5).addClass("selected");});</script><style>.selected { color:red; }</style></head><body><div><ul><li class="above">list item 0</li><li class="top">list item 1</li><li class="top">list item 2</li><li class="middle">list item 3</li><li class="middle">list item 4</li><li class="bottom">list item 5</li><li class="bottom">list item 6</li><li class="below">list item 7</li></ul></div></body>
</html>
This will produce following result −
<html><head><title>The jQuery Example</title><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><script type="text/javascript" language="javascript">$(document).ready(function() {$("li").slice(2, 5).addClass("selected");});</script><style>.selected { color:red; }</style></head><body><div><ul><li class="above">list item 0</li><li class="top">list item 1</li><li class="selected">list item 2</li><li class="selected">list item 3</li><li class="selected">list item 4</li><li class="bottom">list item 5</li><li class="bottom">list item 6</li><li class="below">list item 7</li></ul></div></body>
</html>
This will produce following result −
转载于:https://www.cnblogs.com/hephec/p/4574423.html
jQuery - slice( start, [end] ) Method相关推荐
- 点击“换一换”切换商品,使用jquery slice()实现无缝连接切换
页面需求需要做一个点击换一换按钮,切换商品信息.网上看了一些笨方法,觉得太冗余.自己写了一个精简版的如下: html部分 <div class="layer clearfix qian ...
- slice()如何在jQuery中工作
Earlier we looked how to get an element with specific index in jQuery, but sometimes we want to get ...
- jquery教程_jQuery教程
jquery教程 I have written a lot of jQuery tutorial articles. This is an index post for all the jQuery ...
- HTML中动态图片切换JQuery实现
相信很多同学都注意到了,各大新闻或者娱乐网站都含有动态图片切换,那个漂亮的感觉让刚刚学习html的人,都非常好奇和心动.那下面就让我们看一下到底如何实现动态图片切换呢?看一下百度贴吧的效果图吧~ ...
- jquery学习手记(10)事件简介
1. 使用jquery监听的方法有许多种: // The many ways to bind events with jQuery // Attach an event handler directl ...
- 封装jQuery下载文件组件
使用jQuery导出文档文件 jQuery添加download组件 jQuery.download = function(url, data, method){if( url && d ...
- JavaScript学习笔记(四)——jQuery插件开发与发布
jQuery插件就是以jQuery库为基础衍生出来的库,jQuery插件的好处是封装功能,提高了代码的复用性,加快了开发速度,现在网络上开源的jQuery插件非常多,随着版本的不停迭代越来越稳定好用, ...
- Golang Clearing slice
//first method :slice = nil// second method :slice = slice[0:0] Source page : https://www.socketloop ...
- Jquery+asp.net实现Ajax方式文件下载实例代码
如果文件中,需要下载一个文件,一般用超级链接的方式即可. 但是如果是图片,浏览器会默认打开图片浏览,不是实现下载. 考虑可以使用jquery ajax提交form请求的方式. jquery downl ...
- jquery position
在给元素定位之前,我们首先要了解一些CSS定位相关的知识. 在CSS中关于定位的内容是:position:relative | absolute | static | fixed .static 没有 ...
最新文章
- mysql5.7安装教程图文详解
- Dcoker(系列) docker-redis警告处理
- https://www.unimelb.edu.au/
- 未指定发送trap的源接口_组播之RPF接口检测
- Codeforces 558E A Simple Task
- Asp.Net Core 2.2.0-preview1已经发布
- 【APICloud系列|33】移动应用软件加固步骤,适合所有的安卓应用市场
- es6关于let和const的总结
- java国际化服务器不识别_国际化踩坑记录java.util.MissingResourceException:
- 【语义分割】全卷积网络(Fully Convolutional Networks, FCN)详解
- 隔壁桌的美女同事问我,凭啥子Nginx的并发数可以达到3w?我这次被打脸了~
- 【优化算法】贪婪策略和变异策略的混合蚁群算法【含Matlab源码 1521期】
- Java 实现 HTML 转 PDF 文件
- A Style-Aware Content Loss for Real-time HD Style Transfer(一个风格转换的风格感知损失)CVPR2018
- 基于Vue的单页面格式化数据高亮编辑器组件:兼容json/xml/html/txt多种格式
- 去哪儿网2018春招软件开发工程师、前端开发工程师编程题 - 题解
- 2017小象学院Python数据分析与挖掘
- 换行和禁止换行及超出省略号
- 在线Base64编码 = 图片
- smss.exe之wom毒
热门文章
- Hive启动的三种方式
- Hbase二级索引入门
- Cmake构建_指定gcc/g++版本
- JAVA发送HttpClient请求及接收请求结果过程
- Output error file to the following location:[ A:\GHOST ERR.TXT] 错误处理
- 读《世界是数字的》有感③
- Linux下使用rsync最快速删除海量文件的方法分享
- 【Iphone 游戏开发之一】创建视图并绘制简单图形
- redis的批量操作命令pipeline(PHP实现)
- sublime3环境