Href with click event to execute function

0

I wanted to know if somehow it could be done that when I clicked with href, a function would be executed and how it would be (having jquery and js available). I had something like that but it does not work, thank you very much.

<a href="funcion(x)">Y</a>
    
asked by Ricardo 26.06.2018 в 22:03
source

1 answer

1

It is wrong, the href property in the <a> tags is used to determine the link to which you would redirect the link, for example:

<a href="https://www.google.es/">Google</a>

If what you want is that when you click on the link to execute a JS function you have to use the property onclick :

<button onclick="Funcion()">Hago algo</button>
    
answered by 26.06.2018 / 22:07
source