0
Is it possible to run a function only in javascript without using HTML ? I want the script to look for the id of a button in html and for the onclick function to appear only in the internal code of the script, without having to call it in the button attributes like "" It is possible ?
var play;
var controle = document.getElementById('button');
controle.onclick = function teste()
{
if(document.getElementById("button").value == "Play")
{
document.getElementById("button").value = "Pause";
play = setInterval(trocaBanner,4000);
}
else
{
document.getElementById("button").value = "Play";
clearInterval(play);
}
}
<section class="banner">
<figure>
<input type="button" id="button" value="Play" />
<img src="img/destaque-home.png" alt="Promoção : Big City Night"/
</figure>
</section>
Dude I think you could give a broader description for what you want to do. Edit the question and put the context of what you have, what you want to do and how you expect it to work, because the way it is we have no context of what is happening...
– KhaosDoctor
I edited the question, can you help me ?
– Luis