Condição não funcionando em string
Primeiro, eu sou leigo no assunto e estou tentando aprender sobre funções criando um programa básico!
O problema é que estou tentando fazer uma condição que:
Ao apertar o botão: Abrir Caixa, a ideia é que apareça um alert na tela dizendo que o caixa foi aberto. até aí tudo bem.
Mas queria que, ao pressionar o botão novamente, ele fechasse o caixa.
Pra isso tentei utilizar a própria string do que, quando estivesse escrito 'Caixa Fechado', ele abriria, e quando estivesse 'Caixa Aberto' ele fecharia
o problema é que eu não sei por que o meu js não ta reconhecendo o que está escrito na string, só reconhece que é uma string. (quando tento o mesmo código no node exec, ele funciona) :(
ta aí os Códigos:
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<link rel="stylesheet" href="estilos.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Caixa</title>
</head>
<body>
<div class="lateral" >
<h1 class="" name="txtest" id="estado">Caixa Aberto</h1>
<input type="number" name="txtinit" id="txtinit" class="txtinit">
<input type="button" value="Abrir Caixa" onclick="abrir()" class="open" id="abrir">
</div>
<script src="./main.js"></script>
</body>
</html>
const { app, BrowserWindow } = require('electron')
function createWindow() {
let win = new BrowserWindow({
width: 1360,
height: 720,
fullscreen: false,
frame: true,
webPreferences: {
nodeIntegration: false
}
})
win.loadFile('index.html')
win.removeMenu('index.html')
}
function abrir() {
var estate = window.document.getElementById('estado')
if (estate == 'Caixa Aberto') {
estate = 'Caixa Aberto'
window.alert("O caixa foi Aberto!")
} else {
estate = 'Caixa Fechado'
window.alert("O caixa foi Fechado!")
}
}
app.on('ready', createWindow)
body{
background: rgba(231, 223, 206, 0.37);
}
.word{
background: red;
}
.txtinit{
font-variant-numeric: tabular-nums;
height: 20px;
width: 200;
background: rgba(231, 223, 206, 0.37);
}
.open{
height: 60px;
width: 200px;
margin-top: 500px;
}
.lateral{
text-align: center;
background: rgba(0, 0, 0, 0.74);
margin-top: 20px;
height: 670px;
width: 250px;
}Discussão (3)
Carregando comentários...