Disable link in dropdown menu but keep the css

2019-09-14 01:26发布

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 :)

2条回答
冷血范
2楼-- · 2019-09-14 01:51

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;
 }
查看更多
放荡不羁爱自由
3楼-- · 2019-09-14 01:56

Try this :

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

You will not need to use

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

}
查看更多
登录 后发表回答