Мне было интересно, будет ли эта ссылка вызывать нужную мне функцию?
<a href="http://catalog.bitsltd.us/power_strips#replaced" onclick="document.getElementById('caShip').function caShip()" id="caShip">Some Text</a>
и это функция, которую я хочу вызвать ... Может кто-нибудь сказать мне, почему она также не работает?
<script type="text/javascript">
$(function caShip(){
$('#caShip').replaceWith('Some HTML (the new HTML has an id of replaced)');
});
</script>
Когда ссылка нажата, она переходит к href, который является той же страницей и идентификатором, но он не заменяет новым HTML, который является ?
ОБНОВЛЕНИЕ: ЭТО РАБОЧИЙ КОД:
JS
<script type="text/javascript">
$(document).ready(function(){
//Hide Canadian Information
$('.locationDiv').hide();
//bind the links click events
$('.locLink').click(function(){
$('#1').hide();
$('#desc_' + $(this).attr('title')).show();
});
});
</script>
HTML
<a href="javascript:void(0);" title="can" class="locLink" id="1">Canadian Customers Click Here Before Ordering!</a>
<div id="desc_can" class="locationDiv">
<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>
Я не использовал CSS, потому что без него могу добиться того, что мне нужно. Спасибо всем, кто пытался мне помочь с этим !!!.