0
I have an html page that takes some functions of a Javascript page, but when I open this page by Nodejs javascript does not work. I did the test with simple Javascript and Jquery commands, but both work only if I open my HTML directly
alert("carregado alerta");
$(document).ready(function() {
$('#idQueIdentificaP').text('JAVASCRIPT ALTEROU ESSE P')
});
function alterar(){
$('#idQueIdentificaP').text('JAVASCRIPT ALTEROU ESSE P DE NOVO')
}
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script type="text/javascript" src="mudartexto.js"></script>
<title>"Meu html </title>
</head>
<body>
<h1> Pagina</h1>
<p id="idQueIdentificaP"></p>
<button type="button" onclick="alterar()">alterar de novo</button>
<script type="text/javascript" src="mudartexto.js"></script>
</body>
</html>
call code on Node:
app.get("/pag", function(req,res){
res.sendFile(__dirname + "/html/index.html");
})
Thank you, it worked perfectly.
– Erico Calasans