+ -
当前位置:首页 → 问答吧 → 关于jquery中的一个小问题

关于jquery中的一个小问题

时间:2010-10-18

来源:互联网

html内容:
<p>Hello</p> 
<b>aaaa</b>
现在我想要在<p>后面加一个标签<a href="">href</a>使内容为:
<p>Hello</p> 
<a href="">href</a>
<b>aaaa</b>
为什么用以下方法不行?


$(document).ready(function(){
$("p").add($("<a href="">href</a>"));
});

作者: ucfjepl   发布时间: 2010-10-18

用 append

作者: aspwebchh   发布时间: 2010-10-18

$(document).ready(function(){
$("p").after("<a href="">href</a>");
});

作者: aspwebchh   发布时间: 2010-10-18

$("p").after($("<a href="">href</a>"));

作者: pxynet   发布时间: 2010-10-18

$("p").append("<a href="">href</a>");

或者
$("b").prepend("<a href="">href</a>");

作者: cj205   发布时间: 2010-10-18

引用 4 楼 cj205 的回复:

$("p").append("<a href="">href</a>");

或者
$("b").prepend("<a href="">href</a>");
有误,请忽视

作者: cj205   发布时间: 2010-10-18

那么add那个方法是什么意思呢?

作者: ucfjepl   发布时间: 2010-10-18

add和after有什么区别?

作者: ucfjepl   发布时间: 2010-10-18

有 add吗?

作者: aspwebchh   发布时间: 2010-10-18

引用 8 楼 aspwebchh 的回复:
有 add吗?

有的

作者: ucfjepl   发布时间: 2010-10-18