开发者

How to insert a break tag after ) with jQuery?

The following is an output from an old CMS.

I'd like to insert

<br />

after

(<A HREF="edit-8.asp">Rediger dine kundeopplysninger</A>)

to become

(<A HREF="edit-8.asp">Rediger dine kundeopplysninger</A>)<br />

with jQuery.

<div id="system">
        <FORM ACTION="confirm-8.开发者_JAVA技巧asp" METHOD="post" NAME="kassaForm">
        <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="2" WIDTH="100%">
         <TR>
          <TD CLASS="td-menu" COLSPAN="7">
            Kundeopplysninger
          </TD>
         </TR>
         <TR>
          <TD CLASS="td-main" COLSPAN="7">
            <BR>

            here any name (<A HREF="edit-8.asp">Rediger dine kundeopplysninger</A>)
            here any address<BR>
            <BR>
            2nd part of address<BR>
            <BR>
          </TD>

         </TR>
   more after here.....


Try this:

Example: http://jsfiddle.net/pYTgc/

var textNode = $('#system a[href$="edit-8.asp"]')[0].nextSibling​;

var newValue = textNode.nodeValue.replace(')', ')<br>'); 

$(textNode).replaceWith($('<span/>',{html:newValue}));

Or if you don't want the span there, you can unwrap it.

Example: http://jsfiddle.net/pYTgc/1/

var textNode = $('#system a[href$="edit-8.asp"]')[0].nextSibling​;

var newValue = textNode.nodeValue.replace(')', ')<br>'); 

var span = $('<span/>',{html:newValue});

$(textNode).replaceWith( span );

span.children(':first').unwrap();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜