追加内容,所以我有我的网页上这个网站:使用jQuery从同级
<div class='item'>
<h2><a href='http://www.mysite.com/1'>Link 1</a></h2>
<p class='desc'>Text text text text</p>
</div>
<div class='item'>
<h2><a href='http://www.mysite.com/2'>Link 2</a></h2>
<p class='desc'>Text text text text</p>
</div>
<div class='item'>
<h2><a href='http://www.mysite.com/3'>Link 3</a></h2>
<p class='desc'>Text text text text</p>
</div>
我想追加一个链接到段落的末尾,使用从兄弟H2标签的链接。我有这个jQuery:
$('p.desc').append(' <a href="' + $(this).prev().find('a').attr('href') + '">More ></a>');
但链接只设置为undefined
。我在这里做错了什么?
你不需要的“>”,以“更多”的权利。 – Swordfish0321 2013-05-03 21:45:40
@ Swordfish0321:不要以为这是不需要的,只是想成为'更多'的箭头,他应该做['>'](http://www.w3.org/TR/html4/charset.html #h-5.3.2)。 – 2013-05-03 23:09:18
@Paolo Bergantino是的,我在发表评论后发现,但我留下了后代,因为我认为还应该使用特殊的字符。 – Swordfish0321 2013-05-03 23:15:41