jquery - using a <a> to run a function() -
i wondering link call function want?
<a href="http://catalog.bitsltd.us/power_strips#replaced" onclick="document.getelementbyid('caship').function caship()" id="caship">some text</a>
and function want call... can tell me why not working also?
<script type="text/javascript"> $(function caship(){ $('#caship').replacewith('some html (the new html has id of replaced)'); }); </script>
when link clicked go href, same page , id, doesn't replace < > new html, < div >?
update: working code:
js
<script type="text/javascript"> $(document).ready(function(){ //hide canadian information $('.locationdiv').hide(); //bind 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 there fees associated shipping canada <b><u><i><font color="red">not</font></i></u></b> included in cost of shipping or cost of unit. these cost paid purchaser. here tips shipping canada: <br /> <br /> -usps methods cheap unreliable. <b>border fees</b> not charged using usps, ups or fed ex (which reliable). <br /> -<b>customs fees</b> can sometime run <b>up 50%</b> of purchase price (ups/fedex). <br /> -smart strips available canadian dealer. visit our <a href="index.php?itemid=146" title="store locator" target="_blank">store locator</a> find local seller. <br /> -customers ups or fedex account may ship on account , assume fees no delays. <br /> -canadian customers selecting ups or fedex have pick package @ local station , pay fees. order online, still have drive , pay pick unless used own ups/fed ex account.</span> </td> </tr> </table> </div>
i didn't use css because can achieve need without it. trying me this!!!.
try this...
html
<a href="#replaced" id="caship">some text</a>
js
$('#caship').click(function(){ $(this).text('some html (the new html has id of replaced)'); });
Comments
Post a Comment