My Javascript function is not activated

1

Well, my problem is that I want to activate an action on a label, but it marks me an error and I do not know because if everything is as it should work.

Label

 <a onclick="can();">Cancelar</a>

Function of .js

<script type="text/javascript">

 function can() {
alert("Hola mundo");
 } 


</script>

The error is as follows:

I am developing on the programming language "Ruby on Rails" and the .js is inside my .html.erb file which is where I have my form.

    
asked by David 23.12.2016 в 21:16
source

1 answer

2

The solution to my problem is that it had my function

 function can() {
alert("Hola mundo");
 } 

But also it had another function in the following way

function cancel{
alert("adios mundo");
}

In the second function I had not put the two necessary parentheses, although this was below my first function, when I got to that error it took me out of my script and therefore I decided that I did not recognize the first function.

    
answered by 23.12.2016 / 22:05
source