yoowinsu / blog

issues blog
17 stars 3 forks source link

禁用a链接的方法 #19

Open yoowinsu opened 7 years ago

yoowinsu commented 7 years ago

实现效果如下图:

css方法:

<a href="link.html" class="disabled">链接地址</a>
<style>
  .disabled {
     pointer-events: none;
     cursor: default;
  }
</style>

使用JavaScript来防止这样的默认操作:

 $('.disabled').click(function(e){
     e.preventDefault();
  })