How to append html to first occurance of string after selected element

Posted by uku on Stack Overflow See other posts from Stack Overflow or by uku
Published on 2010-03-23T18:29:53Z Indexed on 2010/03/23 18:33 UTC
Read the original article Hit count: 216

Filed under:
|

Hello,

I have html like so:

<div class=foo>
  (<a href=forum.example.com>forum</a>)
  <p>
  Some html here....
</div>

And I want to insert another link after the first one, like so:

<div class=foo>
  (<a href=forum.example.com>forum</a>) <a href=blog.example.com>blog</a>
  <p>
  Some html here....
</div>

...but because it is enclosed in () I cannot use:

$('div.foo a:first').append(' <a href=blog.example.com>blog</a>');

...which would place it before the ).

So how can I extend my jQuery selection to select the literal ) or do I need to use another solution?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors