6

I would like to replace the following html block:

<table class="t12PageBody" cellpadding="0" cellspacing="0" width="100%" summary="">
  <tr><td colspan="2">#REGION_POSITION_01#</td></tr> 
</table>

<table width="100%" summary="">
 <tr>
  <td class="t12ContentBody" valign="top"> #SUCCESS_MESSAGE# #NOTIFICATION_MESSAGE# #BOX_BODY# #REGION_POSITION_04##REGION_POSITION_05##REGION_POSITION_06##REGION_POSITION_07##REGION_POSITION_08#</td>
  <td align="right" valign="top" class="t12ContentBody">#REGION_POSITION_03#<br /></td>
 </tr>
</table>

with this block:

<div id = "banner">
<div class="Logo"></div>
<img src="http://www.example.com/home/images/spacer.gif" height="35" width="180"  border="0" alt=""> <font class="bannertext">&APPNAME.</font>
<div class="bannerText">
    <div class="hmenu"><ul>&APPLICATION_LINKS.</ul></div>
</div>

I looked at the replace function in jQuery but unsure how to apply.

2 Answers 2

14
var newHTML = '<div id = "banner"><div class="Logo"></div>' +
              '<img src="http://www.abc.com/home/images/spacer.gif" ' + 
              'height="35" width="180"  border="0" alt=""> <font ' + 
              'class="bannertext">&APPNAME.</font><div class="bannerText">' + 
              '<div class="hmenu"><ul>&APPLICATION_LINKS.</ul>' + 
              '</div></div>';
$('table.t12PageBody').replaceWith(newHTML);
Sign up to request clarification or add additional context in comments.

2 Comments

@Matthew would it be possible for you to reformat your entry? break the lines apart or something to make it more readable?
@BerggreenDK I've split it into multiple concatenated strings.
0

If you have a wrapper for where you want to put it, use .html(...)

$('#wrapper').html('<div id = "banner">' + ... );

2 Comments

It's easier just to use the replaceWith function in this case.
for this is required jQuery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.