tags:

views:

19

answers:

2

The following source is created dynamically.

I'd like to add

    <br /> 
after Artikler, to become 
    Artikler<br />.

Source

<div id="shopping">
    <p><!--TEXT:--> <A HREF="cart-8.asp" CLASS="longsum">7&nbsp;Artikler, verdi:&nbsp;10 199,00</A></p>
    </div>

I think I need to use

.after('<br />');

but I am not sure how to get Artikler.

7  will be changed dynamically.

Could you anyone tell me how to do it please.

Thanks in advance.

A: 
"7&nbsp;Artikler, verdi:&nbsp;10 199,00".replace("Artikler", "Artikler<br />");

this should do the thing if i got you correctly

Anpher
+1  A: 

The jQuery DOM manipulation functions (such as after()) work specifically on DOM elements, and in this case your entire block of text is a single element.

A better approach is to get the text out of the element:

var text = $("a.longsum").html();

Then do your string replace:

text = text.replace("Artikler", "Artikler<br />");

and put the result back into the element:

$("a.longsum").html(text);
JacobM
Thanks. It solved the problem.
shin