Jump to content

jQuery - Disabling an anchor


Love2c0de

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
https://forums.phpfreaks.com/topic/282619-jquery-disabling-an-anchor/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.