juqery 学习之五 文档处理 插入_jquery

append(content)
向每个匹配的元素内部追加内容。
这个操作与对指定的元素执行appendChild方法,将它们添加到文档中的情况类似。
--------------------------------------------------------------------------------
Append content to the inside of every matched element.
This operation is similar to doing an appendChild to all the specified elements, adding them into the document.
返回值
jQuery
参数
content (String, Element, jQuery) : C要追加到目标中的内容
示例
向所有段落中追加一些HTML标记。
HTML 代码:
<p>I would like to say: </p>
jQuery 代码:
$("p").append("<b>Hello</b>");
结果:
[ <p>I would like to say: <b>Hello</b></p> ]
-
--------------------------------------------------------------------------------------------------------------------------------------------------
appendTo(content)
把所有匹配的元素追加到另一个、指定的元素元素集合中。
实际上,使用这个方法是颠倒了常规的$(A).append(B)的操作,即不是把B追加到A中,而是把A追加到B中。
--------------------------------------------------------------------------------
Append all of the matched elements to another, specified, set of elements.
This operation is, essentially, the reverse of doing a regular $(A).append(B), in that instead of appending B to A, you're appending A to B.
返回值
jQuery
参数
content (String) :用于被追加的内容
示例
把所有段落追加到ID值为foo的元素中。
HTML 代码:
<p>I would like to say: </p><div id="foo"></div>
jQuery 代码:
$("p").appendTo("#foo");
结果:
<div id="foo"><p>I would like to say: </p></div>
--------------------------------------------------------------------------------------------------------------------------------------------------
prepend(content)
向每个匹配的元素内部前置内容。
这是向所有匹配元素内部的开始处插入内容的最佳方式。
--------------------------------------------------------------------------------
Prepend content to the inside of every matched element.
This operation is the best way to insert elements inside, at the beginning, of all matched elements.
返回值
jQuery
参数
content (String, Element, jQuery) : 要插入到目标元素内部前端的内容
示例
向所有段落中前置一些HTML标记代码。
HTML 代码:
<p>I would like to say: </p>
jQuery 代码:
$("p").prepend("<b>Hello</b>");
结果:
[ <b>Hello</b><p>I would like to say: </p> ]
--------------------------------------------------------------------------------
将一个DOM元素前置入所有段落
HTML 代码:
<p>I would like to say: </p>
<p>I would like to say: </p>
<b class="foo">Hello</b>
<b class="foo">Good Bye</b>
jQuery 代码:
$("p").prepend( $(".foo")[0] );
结果:
<p><b class="foo">Hello</b>I would like to say: </p>
<p><b class="foo">Hello</b>I would like to say: </p>
<b class="foo">Hello</b>
<b class="foo">Good Bye</b>
--------------------------------------------------------------------------------
向所有段落中前置一个jQuery对象(类似于一个DOM元素数组)。
HTML 代码:
<p>I would like to say: </p><b>Hello</b>
jQuery 代码:
$("p").prepend( $("b") );
结果:
<p><b>Hello</b>I would like to say: </p>
--------------------------------------------------------------------------------------------------------------------------------------------------
prependTo(content)
把所有匹配的元素前置到另一个、指定的元素元素集合中。
实际上,使用这个方法是颠倒了常规的$(A).prepend(B)的操作,即不是把B前置到A中,而是把A前置到B中。
--------------------------------------------------------------------------------
Prepend all of the matched elements to another, specified, set of elements.
This operation is, essentially, the reverse of doing a regular $(A).prepend(B), in that instead of prepending B to A, you're prepending A to B.
返回值
jQuery
参数
content (String) :用于匹配元素的jQuery表达式
示例
把所有段落追加到ID值为foo的元素中。
HTML 代码:
<p>I would like to say: </p><div id="foo"></div>
jQuery 代码:
$("p").prependTo("#foo");
结果:
<div id="foo"><p>I would like to say: </p></div>
--------------------------------------------------------------------------------------------------------------------------------------------------
after(content)
在每个匹配的元素之后插入内容。
--------------------------------------------------------------------------------
Insert content after each of the matched elements.
返回值
jQuery
参数
content (String, Element, jQuery) : 插入到每个目标后的内容
示例
在所有段落之后插入一些HTML标记代码。
HTML 代码:
<p>I would like to say: </p>
jQuery 代码:
$("p").after("<b>Hello</b>");
结果:
<p>I would like to say: </p><b>Hello</b>
--------------------------------------------------------------------------------
在所有段落之后插入一个DOM元素。
HTML 代码:
<b id="foo">Hello</b><p>I would like to say: </p>
jQuery 代码:
$("p").after( $("#foo")[0] );
结果:
<p>I would like to say: </p><b id="foo">Hello</b>
--------------------------------------------------------------------------------
在所有段落中后插入一个jQuery对象(类似于一个DOM元素数组)。
HTML 代码:
<b>Hello</b><p>I would like to say: </p>
jQuery 代码:
$("p").after( $("b") );
结果:
<p>I would like to say: </p><b>Hello</b>
--------------------------------------------------------------------------------------------------------------------------------------------------
before(content)
在每个匹配的元素之前插入内容。
--------------------------------------------------------------------------------
Insert content before each of the matched elements.
返回值
jQuery
参数
content (String, Element, jQuery) : 插入到每个目标前的内容
示例
在所有段落之前插入一些HTML标记代码。
HTML 代码:
<p>I would like to say: </p>
jQuery 代码:
$("p").before("<b>Hello</b>");
结果:
[ <b>Hello</b><p>I would like to say: </p> ]
--------------------------------------------------------------------------------
在所有段落之前插入一个元素。
HTML 代码:
<p>I would like to say: </p><b id="foo">Hello</b>
jQuery 代码:
$("p").before( $("#foo")[0] );
结果:
<b id="foo">Hello</b><p>I would like to say: </p>
--------------------------------------------------------------------------------
在所有段落中前插入一个jQuery对象(类似于一个DOM元素数组)。
HTML 代码:
<p>I would like to say: </p><b>Hello</b>
jQuery 代码:
$("p").before( $("b") );
结果:
<b>Hello</b><p>I would like to say: </p>
--------------------------------------------------------------------------------------------------------------------------------------------------
insertAfter(content)
把所有匹配的元素插入到另一个、指定的元素元素集合的后面。
实际上,使用这个方法是颠倒了常规的$(A).after(B)的操作,即不是把B插入到A后面,而是把A插入到B后面。
--------------------------------------------------------------------------------
Insert all of the matched elements after another, specified, set of elements.
This operation is, essentially, the reverse of doing a regular $(A).after(B), in that instead of inserting B after A, you're inserting A after B.
返回值
jQuery
参数
content (String) : 用于匹配元素的jQuery表达式
示例
在所有段落之后插入一个元素。与 $("#foo").after("p")相同
HTML 代码:
<p>I would like to say: </p><div id="foo">Hello</div>
jQuery 代码:
$("p").insertAfter("#foo");
结果:
<div id="foo">Hello</div><p>I would like to say: </p>
-------------------------------------------------------------------------------------------------------------------------------------------------
insertBefore(content)
把所有匹配的元素插入到另一个、指定的元素元素集合的前面。
实际上,使用这个方法是颠倒了常规的$(A).before(B)的操作,即不是把B插入到A前面,而是把A插入到B前面。
--------------------------------------------------------------------------------
Insert all of the matched elements before another, specified, set of elements.
This operation is, essentially, the reverse of doing a regular $(A).before(B), in that instead of inserting B before A, you're inserting A before B.
返回值
jQuery
参数
content (String) : 用于匹配元素的jQuery表达式
示例
在所有段落之前插入一个元素。与 $("#foo").before("p")相同。
HTML 代码:
<div id="foo">Hello</div><p>I would like to say: </p>
jQuery 代码:
$("p").insertBefore("#foo");
结果:
<p>I would like to say: </p><div id="foo">Hello</div>

时间: 2024-09-09 20:04:52

juqery 学习之五 文档处理 插入_jquery的相关文章

juqery 学习之五 文档处理 包裹、替换、删除、复制_jquery

wrap(html) 把所有匹配的元素用其他元素的结构化标记包裹起来. 这种包装对于在文档中插入额外的结构化标记最有用,而且它不会破坏原始文档的语义品质. 这个函数的原理是检查提供的第一个元素(它是由所提供的HTML标记代码动态生成的),并在它的代码结构中找到最上层的祖先元素--这个祖先元素就是包裹元素. 当HTML标记代码中的元素包含文本时无法使用这个函数.因此,如果要添加文本应该在包裹完成之后再行添加. --------------------------------------------

Word文档怎么插入特殊符号

  首先,打开Word2003,单击展开"菜单栏"中的"插入"按钮,选择里面的"符号";如下图 文档怎么插入特殊符号-word文档特殊符号"> 在弹出的"符号"窗口中可以找到自己想要的符号;如下图 当然,我们也可以选择"特殊字符"寻找一些"特殊字符"; 告诉大家个好玩的,我们可以在"字体"中选择 Webdings ,在这里,我们可以发现更多好玩的小图形

怎么用java实现doc文档模板插入数据和表格并导出?急急急,在线等

问题描述 怎么用java实现doc文档模板插入数据和表格并导出?急急急,在线等 我要实现一个模板导出功能,模板包含标题和文字内容,模板中间还有一个表格,和结尾文字.要实现动态添加标题文字,其中表格中内容部分动态添加数据,可能会有多种模板,区别是表格样子不同,都要添加内容,最后整个导出doc文件.有没有demo?各位大神?谢谢了先.下面图片中红色框住部分是要动态添加数据的地方,其他地方是模板原型. 解决方案 下面是我实现的方式,用poi工具. /** * * @param filePath 源文件

在Word2007文档中插入和删除分隔符

我们在编辑Word文档的时候通常会用到分隔符,分隔符包括分页符.分栏符以及分节符等,通过在文字中插入分隔符,可以把将Word文档分成多个部分,我们可以对这些部分做不同的页面设置和灵活排版,满足比较复杂的文档页面要求. 插入分隔符很容易,但是想要删除分隔符的时候很多朋友往往就不知道该怎么操作了.下面我们就以Word2007为例,介绍在Word文档中插入和删除分隔符的方法和技巧. 插入分隔符 在Word2007中插入分隔符很简单,将光标定位到文档中需要插入分隔符的地方,点击菜单栏的"页面布局&quo

在Word文档中插入Cad图的3种方法

在word文件中插入我们绘制的cad图,方法大体上有三种,但是它们达到的效果却并不相同,有的显得精致些,有的显得粗糙些,根据我们写作的目的还要进行相应的再处理,这个过程有一些技巧,现在把它写下来,希望能给读者朋友以启发. 要在word文件中插入一个cad图,可以利用下面的三种方法来实现: 第一种,利用键盘上的"print screen sysrq"来抓取cad图,再通过系统自带的画图软件做进一步的修剪,去掉cad剪贴图中多余的部分,这项工作为了是能使图片在word文件中显示的足够的清晰

如何在Word 2013文档中插入分页符

分页符主要用于在Word2013文档的任意位置强制分页,使分页符后边的内容转到新的一页.使用分页符分页不同于Word2013文档自动分页,分页符前后文档始终处于两个不同的页面中,不会随着字体.版式的改变合并为一页.用户可以通过三种方式在Word2013文档中插入分页符: 方式1:打开Word2013文档窗口,将插入点定位到需要分页的位置.切换到"页面布局"功能区.在"页面设置"分组中单击"分隔符"按钮,并在打开的"分隔符"下拉

如何在Word 2013文档中插入日期和时间

用户可以根据实际需要在Word2013文档中插入日期和时间,并且由于所插入的日期和时间代码是从系统中调用的,因此可以在每次打开该Word文档时自动更新时间,或者只在需要更新时间时进行手动更新.在Word2013文档中插入日期和时间的步骤如下所述: 第1步,打开Word2013文档窗口,且换到"插入"功能区.将插入点光标定位到需要插入日期和时间的位置(正文任意位置或页眉页脚中),然后在"插入"区域单击"日期和时间"按钮,如图2013072832所示

如何在Word 2013文档中插入“新建栏”分节符

"新建栏"分节符是Word2013文档中的一种特殊分节符.使用"新建栏"分节符,可以在设置了分栏的Word文档中的下一栏开始新节."新建栏"分节符没有显示在"分隔符"下拉列表中,用户只能通过修改已经存在的分节符来使用"新建栏"分节符.在Word2013文档中插入"新建栏"分节符的步骤如下所述: 第1步,打开Word2013文档窗口,切换到"页面布局"功能区.在&quo

如何在Word 2013文档中插入分节符

通过在Word2013文档中插入分节符,可以将Word文档分成多个部分.每个部分可以有不同的页边距.页眉页脚.纸张大小等不同的页面设置.在Word2013文档中插入分节符的步骤如下所述: 第1步,打开Word2013文档窗口,将光标定位到准备插入分节符的位置.然后切换到"页面布局"功能区,在"页面设置"分组中单击"分隔符"按钮,如图2013072502所示. 图2013072502 单击"分隔符"按钮 第2步,在打开的分隔符列