I found a code that simulates the click of a button, but I need to call a function in javascript and pass a string, how would that look?
document.getElementById("meuElemento").click();
I found a code that simulates the click of a button, but I need to call a function in javascript and pass a string, how would that look?
document.getElementById("meuElemento").click();
You can call the function directly also:
function evento(string){
console.log(string);
}
<input type="button" id="meuElemento" onclick="evento('Teste')">
put like this:
<a href="#" id="meuElemento" onclick="funcao('minha string')">clique aqui.</a>
<script>
function funcao(string) {
alert(string)
}
document.getElementById("meuElemento").click();
</script>