0
I have a javascript that should run only when the content value of Edit is different from null or empty, but the same is always running.
<script type="text/javascript">
function AdicionarClasseMenuSelecionado(){
var menuatual = document.getElementById('MenuSelecionado').value;
var abaatual = document.getElementById('AbaSelecionado').value;
alert(menuatual);
alert(abaatual);
//remove todos os active do cabecalho
$("ul.nav.nav-tabs li").removeClass("active");
//remove todos os active do content
$(".tab-content div").removeClass("active in");
//adiciona o active que retornou
$("#"+menuatual).addClass("active in");
$("#"+abaatual).addClass("active");
};
$(document).ready(function(){
var menuatual = document.getElementById('MenuSelecionado').value;
if (menuatual != null && menuatual != undefined) {
AdicionarClasseMenuSelecionado();
} else {
alert("não foi enviado nenhum menu");
}
});
</script>
Html:
<input name="MenuSelecionado" type="hidden" value="null" id="MenuSelecionado">
<input name="AbaSelecionado" type="hidden" value="null" id="AbaSelecionado">
ou vazio
, did not speak for example a|| menuatual == ""
to validate if it is empty?null
andundefined
are different from empty– Ricardo Pontual
Man, it’s not very nice to mix the syntax of Javascript with that of the jQuery.
– LeAndrade