I'm learning JS and I can not figure out why not change the text of h1 when I click on it.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Testes JavaScript</title>
</head>
<body>
<h1 id="title">Somente alguns testes em JS</h1>
<script>
var x = document.getElementById("title");
x.onclick = {
clicado: 0,
click: function(){
this.innerHTML = "teste";
clicado = 1;
},
check: function(){
if(clicado === 0){
return false;
}else if (clicado === 1){
return true;
}
}
};
x.onclick.click();
</script>
</body>
</html>