So I have this function called redireccionar()
function redireccionar(){
alert("activaste la funcion");
}
and redireccionar() gets called by this:
<button class="btn btn-default" onclick="redireccionar()" type="button">Go!</button>
But I do click and nothing happens, its because I render them? How can I fix it? Why it doesnt work? Thanks.
3 Answers 3
You need to make a separate <script> tag for your custom JS, your first screenshot (http://gyazo.com/c86b48f3f96137bba0e32e1ae72c0daf) shows you have a script tag pulling in bootstrap and within that tag you are specifying your code.
Example solution:
<script src='/path/to/bootstrap/cdn'></script>
<script>
function redireccionar(){
alert("activaste la funcion");
}
</script>
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-src
5 Comments
Oh! I just checked your picture and found something like this:
<script src="......bootstrap.min.js">
//your code here
</script>
You shouldn't include your script within that bootstrap framework. Do like this:
<script src="path-of-boostrap.min.js"></script>
<script>
//your code here
</script>
1 Comment
¡Hola Ruben! Your first screenshot shows the problem. Your function has to be surrounded by separate <script></script> tags, not inside of the linked bootstrap js file. Everything else should be fine so far.
its because I render them???<script>