insertBefore(content) 返回值:jQuery
概述
把所有匹配的元素插入到另一个、指定的元素元素集合的前面。
实际上,使用这个方法是颠倒了常规的$(A).before(B)的操作,即不是把B插入到A前面,而是把A插入到B前面。
在jQuery 1.3.2中,appendTo, prependTo, insertBefore, insertAfter, 和 replaceAll这个几个方法成为一个破坏性操作,要选择先前选中的元素,需要使用end()方法,参见 appendTo 方法的例二。
参数
contentString
用于匹配元素的jQuery表达式
示例
描述:
把所有段落插入到一个元素之前。与 $("#foo").before("p")相同。
HTML 代码...
insertAfter(content) 返回值:jQuery
概述
把所有匹配的元素插入到另一个、指定的元素元素集合的后面。
实际上,使用这个方法是颠倒了常规的$(A).after(B)的操作,即不是把B插入到A后面,而是把A插入到B后面。
在jQuery 1.3.2中,appendTo, prependTo, insertBefore, insertAfter, 和 replaceAll这个几个方法成为一个破坏性操作,要选择先前选中的元素,需要使用end()方法,参见 appendTo 方法的例二。
参数
contentString
用于匹配元素的jQuery表达式
示例
描述:
把所有段落插入到一个元素之后。与 $("#foo").after("p")相同
HTML 代码:
&l...
Top [不推荐]
new Insertion.Top(element, html)
将 html 插入到页面中作为 element 的最前面的子节点。
从 Prototype 1.6 开始,Insertion 类已经完全被 Element#insert 取代。
注意,如果插入的 HTML 包含有 <script> 标签,在插入后标签中的脚本会被自动执行 (Insertion.Top 在内部调用 String#evalScripts)。
样例
初始的 HTML
<div id="modern_major_general">
<p>I am the very model of a modern major general.</p>
</div>
JavaScript
new Insertion.Top(
'modern_major_general',
"<p>In short, in all things vegetable, ani...
Bottom [不推荐]
new Insertion.Bottom(element, html)
将 html 插入到页面中作为 element 的最后的子节点。
从 Prototype 1.6 开始,Insertion 类已经完全被 Element#insert 取代。
注意,如果插入的 HTML 包含有 <script> 标签,在插入后标签中的脚本会被自动执行 (Insertion.Bottom 在内部调用 String#evalScripts)。
样例
初始的 HTML
<div id="modern_major_general">
<p>In short, in all things vegetable, animal, and mineral...</p>
</div>
JavaScript
new Insertion.Bottom(
'modern_major_general',
"<p>I am the very mod...
Before [不推荐]
new Insertion.Before(element, html)
将 html 插入到页面中作为 element 的前导兄弟节点。
从 Prototype 1.6 开始,Insertion 类已经完全被 Element#insert 取代。
注意,如果插入的 HTML 包含有 <script> 标签,在插入后标签中的脚本会被自动执行 (Insertion.Before 在内部调用 String#evalScripts)。
样例
初始的 HTML
<div>
<p id="modern_major_general">
I am the very model of a modern major general.
</p>
</div>
JavaScript
new Insertion.Before(
'modern_major_general',
"<p>In short, in all thin...
After [不推荐]
new Insertion.After(element, html)
将 html 插入到页面中作为 element 的后继兄弟节点。
从 Prototype 1.6 开始,Insertion 类已经完全被 Element#insert 取代。
注意,如果插入的 HTML 包含有 <script> 标签,在插入后标签中的脚本会被自动执行 (Insertion.After 在内部调用 String#evalScripts)。
样例
初始的 HTML
<div>
<p id="animal_vegetable_mineral">
In short, in all things vegetable, animal, and mineral...
</p>
</div>
JavaScript
new Insertion.After(
'animal_vegetable_mineral',
"<p>I am th...
从 Prototype 1.6 开始,Insertion 类已经完全被 Element#insert 取代。
Insertion 用于动态插入 HTML 片断(显然,纯文本也包括在内),它提供了跨浏览器的支持。 可以采用四种方式进行插入:After、Before、Bottom 和 Top,它们所表现出来的行为正如它们的名字一样。
注意,如果插入的 HTML 包含有 <script> 标签,在插入后标签中的脚本会被自动执行 (Insertion 在内部调用 String#evalScripts)。
方法
After [不推荐]
new Insertion.After(element, html)
将 html 插入到页面中作为 element 的后继兄弟节点。
Before [不推荐]
new Insertion.Before(element, html)
将 html 插入...
insert [1.6]
insert(element, { position: content }) -> HTMLElement
insert(element, content) -> HTMLElement
根据第二个参数 position 属性指定的位置,插入 content 到元素的前面、后面、顶部或底部。 如果第二个参数仅包括 content,则将 content 追加到 element 中。
译注:position 取值为:before、after、top 或 bottom。
可插入的内容为以下几种类型:文本、HTML、DOM 元素以及具有 toHTML 或 toElement 方法的任何对象。
注意:如果插入的 HTML 包含 <script> 标签,插入后将会自动运行标签中所包含的 Javascript 代码(插入 HTML 时,insert...
insert(element, { position: content }) -> HTMLElement
insert(element, content) -> HTMLElement
根据第二个参数 position 属性指定的位置,插入 content 到元素的前面、后面、顶部或底部。 如果第二个参数仅包括 content,则将 content 追加到 element 中。
译注:position 取值为:before、after、top 或 bottom。
可插入的内容为以下几种类型:文本、HTML、DOM 元素以及具有 toHTML 或 toElement 方法的任何对象。
注意:如果插入的 HTML 包含 <script> 标签,插入后将会自动运行标签中所包含的 Javascript 代码(插入 HTML 时,insert 方法内部调用了 String#evalScripts 方法)。
...
<script src="prototype.js"></script>
<div id="div1" style="font-size:20px;font-weight:bold">
<hr>基线<hr>
</div>
<script>
new Insertion.After("div1", " After");
new Insertion.Bottom("div1", " Bottom");
new Insertion.Top("div1", " Top");
new Insertion.Before("div1", " Before");
</script>...
mysql_insert_id – 取得上一步 INSERT 操作产生的 ID
int mysql_insert_id ( [resource link_identifier])
mysql_insert_id() 返回给定的 link_identifier 中上一步 INSERT 查询中产生的 AUTO_INCREMENT 的 ID 号。如果没有指定 link_identifier,则使用上一个打开的连接。
如果上一查询没有产生 AUTO_INCREMENT 的值,则 mysql_insert_id() 返回 0。如果需要保存该值以后使用,要确保在产生了值的查询之后立即调用 mysql_insert_id()。
注: MySQL 中的 SQL 函数 LAST_INSERT_ID() 总是保存着最新产生的 AUTO_INCREMENT 值,并且不会在查询语...
mysql中insert into和replace into以及insert ignore用法区别: mysql中常用的三种插入数据的语句: insert into表示插入数据,数据库会检查主键,如果出现重复会报错; replace into表示插入替换数据,需求表中有PrimaryKey,或者unique索引,如果数据库已经存在数据,则用新数据替换,如果没有数据效果则和insert into一样; insert ignore表示,如果中已经存在相同的记录,则忽略当前新数据; 下面通过代码说明之间的区别,如下: create table testtb( id int not null primary key, name varchar(50), age int ); insert into testtb(id,name,age)values(1,"bb",13); select * from testtb; insert ignore into testtb(id,name,a...