Juery手册 专题
专题目录
您的位置:JS框架 > Juery手册专题 > Jquery1.7-insertBefore(content)
Jquery1.7-insertBefore(content)
作者:--    发布时间:2019-11-21

返回值:jqueryinsertbefore(content)

概述

把所有匹配的元素插入到另一个、指定的元素元素集合的前面。

实际上,使用这个方法是颠倒了常规的$(a).before(b)的操作,即不是把b插入到a前面,而是把a插入到b前面。

在jquery 1.3.2中,appendto, prependto, insertbefore, insertafter, 和 replaceall这个几个方法成为一个破坏性操作,要选择先前选中的元素,需要使用end()方法,参见 appendto 方法的例二。

参数

contentstringv1.0

用于匹配元素的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>
网站声明:
本站部分内容来自网络,如您发现本站内容
侵害到您的利益,请联系本站管理员处理。
联系站长
373515719@qq.com
关于本站:
编程参考手册