How to block a <a> tag with javascript

Asked

Viewed 50 times

1

I have a Step by Step I need to cancel the ticket to the next page...

This is my code :

  var nome = document.getElementById('nome').value;
  var resposta = true;
  if(nome == ''){

    var resposta = false;

  }
        if(resposta == false){

         //desabilitar <a>

        }else{

          //habilitar <a>
                 
        }
//esse é o meu link reponsavel por passar o step
<a href="#next" id="proximonext"  role="menuitem" >Proximo</a>

illustrative images inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

if I haven’t been clear , please don’t close my post , just ask that I give more details... thanks!!

1 answer

0


If I understand "disable" correctly, you can do the following:

$("#proximonext").attr('href', 'javascript:void(0)');

And if the variable resposta has true as a value, replace the 'javascript:void(0)' by the desired link.

To understand the use of void with manipulation of the attribute href within Javascript, I recommend reading the Mozilla documentation.

I hope I’ve helped in some way.

  • I’ll try friend!

  • It worked!! Thank you very much!!

  • I’m happy to help. And as the answer helped you, please mark it as "best answer" if possible.

Browser other questions tagged

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