Как заменить блок HTML с другим блоком HTML с помощью jQuery

Я хотел бы заменить следующий блок HTML:

<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>

с этим блоком:

<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>

Я посмотрел на функцию замены в jQuery, но не уверенный, как подать заявку.

5
задан halfer 23 October 2019 в 22:51
поделиться

2 ответа

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);
13
ответ дан 18 December 2019 в 14:43
поделиться

Если у вас есть оболочка, в которую вы хотите ее поместить, используйте .html (...)

$('#wrapper').html('<div id = "banner">' + ... );
0
ответ дан 18 December 2019 в 14:43
поделиться
Другие вопросы по тегам:

Похожие вопросы: