after() 方法在被选元素后插入指定的内容。
工具/原料
jquery
方法/步骤
1
after 有两个参数content 插入到每个目标后的内容function 函数必须返回一个html字符串。
2
示例:在所有段落之后插入一些HTML标记代码。HTML 代码:
I would like to say:
3
jQuery 代码:$('p').after('Hello');
4
结果:
I would like to say:
Hello5
在所有段落之后插入一个DOM元素。HTML 代码:Hello
I would like to say:
6
jQuery 代码:$('p').after( $('#foo')[0] );
7
结果:
I would like to say:
Hello