views:

51

answers:

2

Updated

The following is an output from a old CMS. I would like to insert a break tag after 'Klikk her om du er privatkunde! '.

From this,

<TR>
 <TD CLASS="td-main" COLSPAN="6">
 <A HREF="link to some page">Other link here.</A>
 <A HREF="link to some page">There could be other link, but may be.</A>
 </TD>
 </TR>
...
 <TR>
 <TD CLASS="td-main" COLSPAN="6">
 <A HREF="edit-8.asp?CustType=1">Klikk her om du er privatkunde</A>!
 <A HREF="edit-8.asp?CustType=2">Klikk her om du er bedriftskunde</A>!
 </TD>
 </TR>
...

to this.

...
...
...
<TR>
<TD CLASS="td-main" COLSPAN="6">
<A HREF="edit-8.asp?CustType=1">Klikk her om du er privatkunde</A>!

<br />

<A HREF="edit-8.asp?CustType=2">Klikk her om du er bedriftskunde</A>!
</TD>
</TR>

Could anyone tell me how to do it please?

Thanks in advance.

What I came up is this, but it does not work.

if(location.pathname.indexOf('edit-8') > 0){
$('td[value|=Klikk her om du er privatkunde!]').replaceWith('Klikk her om 
du er privatkunde!<br />')
}
+1  A: 
jessegavin
Agreed. Also, what if the the `a` after the link of interest is deleted?... who knows where that line break will end up then.
Peter Ajtai
+1  A: 

If selecting by the href is unique, you can use .before() and an attribute-equals selector for this:

$("a[href='edit-8.asp?CustType=2']").before("<br />");
Nick Craver