Keep menu item disabled

Asked

Viewed 113 times

0

How to keep a menu item temporarily disabled on the site?

<li><a href='cadastrar.php'>CADASTRAR</a></li>

Grateful.

  • If possible, post the code you have so far, HTML or javascript, and in which situation it should be enabled/disabled.

  • <li><a href="register.php">REGISTER</a></li>

  • I want to disable it temporarily until the page is consolidated.

  • Guy just take the link from the LI and make a CSS any pro Register. <li style="color:#ddd;">CADASTRAR</li> Your question is not very clear.

2 answers

0


It is possible to disable the default action by Javascript.

With jQuery:

$("a[href='cadastrar.php']").click(function (e) {
    e.preventDefault();
});

With native Javascript:

var el = document.querySelectorAll("a[href='cadastrar.php']");

el[0].addEventListener("click", function(e){
    e.preventDefault();
});

-1

You can do this with css and leaving no link inside "href":

.link{
cursor:auto;
}
<li><a class="link" href='#'>CADASTRAR</a></li>

  • Thank you all! Now, how to flag ? Which of the first 3 options should I click?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.