0
Hello! Here’s the thing, in my form, I’m trying to get the value typed by the user in the input way below:
// jQuery
function teste() {
var nome = $("#nome").val();
alert(nome);
}
// HTML
<form method="post" action="#">
<div class="field half first">
<label for="nome">Nome</label>
<input type="text" name="nome" id="nome">
</div>
<div class="field half">
<label for="sobrenome">Sobrenome</label>
<input type="text" name="sobrenome" id="sobrenome">
</div></form>
<button onClick="teste()">Teste</button>
But it returns no value, generates a blank Alert() regardless of what the user has typed. Does anyone know what it might be? If useful, I am using Codeigniter
This can happen if you have more than one element with the same ID.
– Valdeir Psr
I checked that possibility, but there’s only one element with the same ID
– Fábio Espíndola