Disable link in dropdown menu but keep the css

柔情痞子 提交于 2019-12-25 08:33:30

问题


I have the following menu on jsfiddle : http://jsfiddle.net/aL7Xe/1000/

I disabled the "Bewerkingen" link with :

 a[href="/test4/disabled"] {
      pointer-events: none;

}

because its a dropdown menu, but when I use that code my css seems to dissapear, how can I fix this? or what code should I use to disable that link but still have my dropdown menu and css on it ? I am using Drupal so using # in the link is not going to work

Thanks in advance for any help :)


回答1:


Try this :

<a href='#'>Bewerkingen</a>

You will not need to use

a[href="/test4/disabled"] {
      pointer-events: none;

}



回答2:


I'm able to figure about one way, that's by using js.

HTML

<a href="/test4/disabled" class="disable-link">Bewerkingen</a>

JS

$('.disable-link').on('click', function(e) {
   e.preventDefault();
});

I will upadte soon if I got some way to do with css

The other solution with css below, You don't need js now.

.disable-link {
  pointer-events: none;
  cursor: default;
 }


来源:https://stackoverflow.com/questions/41851180/disable-link-in-dropdown-menu-but-keep-the-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!