你好我是新来的,没有看到任何像我的问题。这可能听起来很简单,但似乎不起作用。我正在尝试用其他一些html替换id ='CAShip'的div。
这是代码。 jquery:
<script type="text/javascript">
$('#CAShip').click(function(){
$('#CAShip').replaceWith('New HTML code');
});
</script>
这是起始的html:
<div id="CAShip">
<table class="contentpaneopen">
<tr>
<td class="contentheading" width="100%">Canadian Customers Click Here Before Ordering!
</td>
</tr>
</table>
</div>
这是我要用以下内容替换它的HTML:
<div>
<table class="contentpaneopen">
<tr>
<td class="contentheading" width="100%">Attention Canadian Customers!
</td>
</tr>
</table>
<table class="contentpaneopen">
<tr>
<td valign="top" >
<span class="body">Please note that there are fees associated with shipping to Canada from the US that are <b><u><i><font color="red">NOT</font></i></u></b> included in the cost of the shipping or the cost of the unit. These cost are to be paid for by the purchaser. Here are some tips for shipping to Canada:
<br />
<br />
-USPS methods are cheap but very unreliable. <b>Border fees</b> are not charged using USPS, only UPS or Fed Ex (which are the most reliable).
<br />
-<b>Customs fees</b> can sometime run <b>up to 50%</b> of the purchase price (UPS/FedEx).
<br />
-Smart Strips are available from a Canadian dealer. Visit our <a href="index.php?Itemid=146" title="Store Locator" target="_blank">Store Locator</a> to find a local seller.
<br />
-Customers with a UPS or FedEx account may ship on their account and assume all fees with no delays.
<br />
-Canadian customers selecting UPS or FedEx will have to pick the package up at their local station and pay the fees. So you order it online, but still have to drive and pay to pick it up unless you used your own UPS/Fed Ex account.</span>
</td>
</tr>
</table>
</div>
有什么建议吗?
答案 0 :(得分:2)
您需要将代码包装在ready
处理程序中:
<script type="text/javascript">
$(function(){
$('#CAShip').click(function(){
$('#CAShip').replaceWith('New HTML code');
});
});
</script>