How to prevent the anchor tag to go to its URL
Hey guys
i have an anchor tag in .html page
<a id="add" onclick="javascript:openPage()">yes</a>
this openPage function is on another .js file and i i also added a code for preventing the the anchor thag when cliked to go to the url but do its task,
- var openPage=function(){
- location.href="http://localhost:8080/magento/index.php/checkout/cart/add?"+id+"&qty;=1";
- }
- $('add').bind("click",function(event) {
- event.preventDefault();
- /*var url = $(this).attr("href");*/
- var url="http://localhost:8080/magento/index.php/checkout/cart/add?"+id+"&qty;=1";
- $.get(url, function (resp) {
- alert("Product added to cart");
- });
- });
but the above code..$('add').bind().. is not working. idont if i am doing something wrong.
Please help me out