Jump to content

jQuery - Disabling an anchor


Love2c0de
Go to solution Solved by requinix,

Recommended Posts

Good morning,

 

I have a link on my website which has a default href value. The reason I set an initial value is so that if JS is disabled, it will direct them to another page.

 

My jQuery is supposed to open a 'tooltip' next to the link - which it does - but I want to be able to disable the href so that it points to nowhere so the tooltip activates and the href points to nowhere but can't figure out how to do it. It keeps loading the default page.

 

Here is my code:

 

$(function(){
      $("#technologies,#marketing,#google_analytics").fadeIn(2000);
 
 
 $(".tool").attr("href","#");          
 $(".tool").css("cursor","default");
 
 $(".tool").hover(function(e){
 
var Xpage = e.pageX;
var Ypage = e.pageY;
var title = $(this).attr("data-pack");
var div = "<div class='tooltip'>"+title+"</div>";
console.log(div);
$("body").append(div);
$(".tooltip").css("top", Ypage-90);
$(".tooltip").css("left", Xpage+15);
 
$(".tooltip").fadeIn(500);
 
 }, function(){
 
$(".tooltip").remove();
 
 });
 
});

 

Thanks for your time.

 

Kind regards,

 

L2c.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.