函数:after(content)

功能:在每个匹配的元素后面添加html内容

返回:jQuery对象

参数:content (<Content>): Content to insert after each target. 

例子:

Inserts some HTML after all paragraphs.



jQuery Code

$("p").after("<b>Hello</b>");

Before

<p>I would like to say: </p>

Result:

<p>I would like to say: </p><b>Hello</b>



Inserts an Element after all paragraphs.



jQuery Code

$("p").after( $("#foo")[0] );

Before

<b id="foo">Hello</b><p>I would like to say: </p>

Result:

<p>I would like to say: </p><b id="foo">Hello</b>



Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs.



jQuery Code

$("p").after( $("b") );

Before

<b>Hello</b><p>I would like to say: </p>

Result:

<p>I would like to say: </p><b>Hello</b>





函数:append(content)

功能:在每个匹配元素之内添加content内容

返回:jQuery对象

参数:content (<Content>): Content to append to the target 

例子:

Appends some HTML to all paragraphs.



jQuery Code

$("p").append("<b>Hello</b>");

Before

<p>I would like to say: </p>

Result:

<p>I would like to say: <b>Hello</b></p>



Appends an Element to all paragraphs.



jQuery Code

$("p").append( $("#foo")[0] );

Before

<p>I would like to say: </p><b id="foo">Hello</b>

Result:

<p>I would like to say: <b id="foo">Hello</b></p>



Appends a jQuery object (similar to an Array of DOM Elements) to all paragraphs.



jQuery Code

$("p").append( $("b") );

Before

<p>I would like to say: </p><b>Hello</b>

Result:

<p>I would like to say: <b>Hello</b></p>





函数:appendTo(content)

功能:和append(content)类似,只不过是将前面匹配的元素添加到后面的元素内

返回:jQuery对象

参数:content (<Content>): Content to append to the selected element to. 

例子:

Appends all paragraphs to the element with the ID "foo"



jQuery Code

$("p").appendTo("#foo");

Before

<p>I would like to say: </p><div id="foo"></div>

Result:

<div id="foo"><p>I would like to say: </p></div>





函数:before(content)

功能:在匹配元素之前添加内容

返回:jQuery对象

参数:content (<Content>): Content to insert before each target. 

例子:

Inserts some HTML before all paragraphs.



jQuery Code

$("p").before("<b>Hello</b>");

Before

<p>I would like to say: </p>

Result:

<b>Hello</b><p>I would like to say: </p>



Inserts an Element before all paragraphs.



jQuery Code

$("p").before( $("#foo")[0] );

Before

<p>I would like to say: </p><b id="foo">Hello</b>

Result:

<b id="foo">Hello</b><p>I would like to say: </p>



Inserts a jQuery object (similar to an Array of DOM Elements) before all paragraphs.



jQuery Code

$("p").before( $("b") );

Before

<p>I would like to say: </p><b>Hello</b>

Result:

<b>Hello</b><p>I would like to say: </p>





函数:clone(deep)

功能:克隆dom元素

返回:jQuery对象

参数:deep (Boolean): (可选的) 是否克隆子节点及其自身

例子:

Clones all b elements (and selects the clones) and prepends them to all paragraphs.



jQuery Code

$("b").clone().prependTo("p");

Before

<b>Hello</b><p>, how are you?</p>

Result:

<b>Hello</b><p><b>Hello</b>, how are you?</p>





函数:empty()

功能:移除匹配元素的子节点

返回:jQuery对象

例子:

jQuery Code

$("p").empty()

Before

<p>Hello, <span>Person</span> <a href="#">and person</a></p>

Result:

[ <p></p>





函数:insertAfter(content)

功能:将匹配元素插入到content插入到之后

返回:jQuery对象

参数:Content to insert the selected element after

例子:

jQuery Code

$("p").insertAfter("#foo");

Before

<p>I would like to say: </p><div id="foo">Hello</div>

Result:

<div id="foo">Hello</div><p>I would like to say: </p>





函数:insertBefore(content)

功能:将匹配元素插入到content插入到之前

返回:jQuery对象

参数:Content to insert the selected element before.

例子:

jQuery Code

$("p").insertBefore("#foo");

Before

<div id="foo">Hello</div><p>I would like to say: </p>

Result:

<p>I would like to say: </p><div id="foo">Hello</div>





函数:prepend(content)

功能:与append相反,append是添加到匹配元素子节点之后,prepend是添加到匹配元素子节点之前

返回:jQuery对象

参数: Content to prepend to the target. 

例子:

jQuery Code

$("p").prepend("<b>Hello</b>");

Before

<p>I would like to say: </p>

Result:

<p><b>Hello</b>I would like to say: </p>



jQuery Code

$("p").prepend( $("#foo")[0] );

Before

<p>I would like to say: </p><b id="foo">Hello</b>

Result:

<p><b id="foo">Hello</b>I would like to say: </p>



$("p").prepend( $("b") );

Before

<p>I would like to say: </p><b>Hello</b>

Result:

<p><b>Hello</b>I would like to say: </p>





函数:prependTo(content)

功能:将前面元素添加到后面元素子节点的前面

返回:jQuery对象

参数:content (<Content>): Content to prepend to the selected element to. 

例子:

jQuery Code

$("p").prependTo("#foo");

Before

<p>I would like to say: </p><div id="foo"><b>Hello</b></div>

Result:

<div id="foo"><p>I would like to say: </p><b>Hello</b></div>





函数:remove(expr)

功能:移除匹配元素

功能:jQuery对象

参数:expr (String): (optional) A jQuery expression to filter elements by. 

例子:

jQuery Code

$("p").remove();

Before

<p>Hello</p> how are <p>you?</p>

Result:

how are



jQuery Code

$("p").remove(".hello");

Before

<p class="hello">Hello</p> how are <p>you?</p>

Result:

how are <p>you?</p>





函数:wrap(html)

功能:对匹配元素用html包裹起来

返回:jQuery对象

参数:

例子:

jQuery Code

$("p").wrap("<div class='wrap'></div>");

Before

<p>Test Paragraph.</p>

Result:

<div class='wrap'><p>Test Paragraph.</p></div>





函数:wrap(elem)

功能:对指定元素用html包裹起来

参数:

例子:

jQuery Code

$("p").wrap( document.getElementById('content') );

Before

<p>Test Paragraph.</p><div id="content"></div>

Result:

<div id="content"><p>Test Paragraph.</p></div>

jQuery函数学习的更多相关文章

  1. jQuery源代码学习_工具函数_type

    jquery源代码学习_工具函数_type jquery里面有一个很重要的工具函数,$.type函数用来判断类型,今天写这篇文章,是来回顾type函数的设计思想,深入理解. 首先来看一下最终结果: 上 ...

  2. jQuery源代码学习笔记_工具函数_noop/error/now/trim

    jQuery源代码学习笔记_工具函数_noop/error/now/trim jquery提供了一系列的工具函数,用于支持其运行,今天主要分析noop/error/now/trim这4个函数: 1.n ...

  3. jQuery源代码学习笔记:jQuery.fn.init(selector,context,rootjQuery)代码具体解释

    3.1 源代码 init: function( selector, context, rootjQuery ) { var match, elem, ret, doc; // Handle $(&qu ...

  4. Jquery重新学习之七[Ajax运用总结A]

    Jquery中Ajax的运用是另外一个重点,平时项目经常会用它进行一些异步操作:其核心是通过XMLHttpRequest对象以一种异步的方式,向服务器发送数据请求,并通过该对象接收请求返回的数据,从而 ...

  5. jQuery框架学习第十一天:实战jQuery表单验证及jQuery自动完成提示插件

    jQuery框架学习第一天:开始认识jQueryjQuery框架学习第二天:jQuery中万能的选择器jQuery框架学习第三天:如何管理jQuery包装集 jQuery框架学习第四天:使用jQuer ...

  6. 第十九篇 jQuery初步学习

    jQuery 初步学习   jQuery可以理解为是一种脚本,需要到网上下载,它是一个文件,后缀当然是js的文件,它里面封装了很多函数方法,我们直接调用即可,就比方说,我们用JS,写一个显示与隐藏,通 ...

  7. Python3中的字符串函数学习总结

    这篇文章主要介绍了Python3中的字符串函数学习总结,本文讲解了格式化类方法.查找 & 替换类方法.拆分 & 组合类方法等内容,需要的朋友可以参考下. Sequence Types ...

  8. jQuery 顺便学习下CSS选择器 奇偶匹配nth-child(even)

    今天学习jQuery,看到nth-child(even)用法,特意找了下这个选择器的用法,在CSS3标准中,用法很强大. 对此,我把CSS3标准中nth-child()用法大致介绍下: CSS3伪类选 ...

  9. Drools 函数学习

    Drools 函数学习 函数是定义在规则文件当中一代码块,作用是将在规则文件当中若干个规则都会用到的业务操作封装起来,实现业务代码的复用,减少规则编写的工作量.函数的编写位置可以是规则文件当中 pac ...

随机推荐

  1. ThreadPoolExecutor线程池参数设置技巧

    一.ThreadPoolExecutor的重要参数   corePoolSize:核心线程数 核心线程会一直存活,及时没有任务需要执行 当线程数小于核心线程数时,即使有线程空闲,线程池也会优先创建新线 ...

  2. THUWC2018滚粗记

    THUWC2018滚粗记 前言 又是一篇滚粗记, 不过可能还要写过很多很多篇滚粗记, 才会有一篇不是滚粗记的东西啦 总而言之,我现在还是太菜了 还要过一大段时间我才会变强啦 Day -inf 联赛考完 ...

  3. [BZOJ1053] [HAOI2007] 反素数ant (搜索)

    Description 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4. 如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数.例如,整数 ...

  4. 魔改版ss-panel v3前端配置文件

    配置文件所在目录:网站根目录/config/.config.php <?php // ss-panel v3 配置 // // !!! 修改此key为随机字符串确保网站安全 !!! $Syste ...

  5. angular何时触发脏检查机制

    ng只有在指定事件触发后,才进入$digest cycle: DOM事件,譬如用户输入文本,点击按钮等.(ng-click) XHR响应事件 ($http) 浏览器Location变更事件 ($loc ...

  6. Windows Developer Day - MSIX and Advanced Installer

    前面一篇我们介绍了 Adaptive Cards 的基础知识,而在 Windows Developer Day 的 Modern Application Experience 环节,还有一个需要划重点 ...

  7. 浅析git

    git是什么 简单来说,Git,它是一个快速的 分布式版本控制系统 (Distributed Version Control System,简称 DVCS) . 同传统的 集中式版本控制系统 (Cen ...

  8. CyQ.data MDataTable

    前言 以前一两个月才出一篇,这三天有点变态地连续1天1篇(其实都是上周末两天写好的存货). 短期应该没有新的和此框架相关的文章要写了,这应该是最后一篇,大伙且看且珍惜. 前两篇讲数据库读写分享和分布式 ...

  9. Redis学习日记-01

    Redis是什么东东? Redis是用C语言开发的Key-Value数据库,说是数据库,其实他是NoSql(非关系型数据库). 这里顺便说一下Sql(关系型数据库,如MySql,Oracle等)和No ...

  10. python-kafka实现produce与consumer

    1.python-kafka: api送上:https://kafka-python.readthedocs.io/en/latest/apidoc/KafkaConsumer.html 2.实现一个 ...