transpor simples código javascript para JQUERY
pessoal.
simples, como poderia transpor este código de JS para JQUERY?
function openNav() {
document.getElementById("navbar_myside").style.width = "100px";
document.getElementById("wrapper").style.marginLeft = "100px";
//document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
}
function closeNav() {
document.getElementById("navbar_myside").style.width = "0";
document.getElementById("wrapper").style.marginLeft = "0";
//document.body.style.backgroundColor = "white";
}
mais incluindo este abaixo:
1) se clicado, muda o atributo de OPENNAV para CLOSENAV?
2) e ao contrário, de CLOSENAV para OPENNAV, usando IF ELSE para os dois.
Tentei assim, mas não foi...
clicked = true;
$("btn_open").click(function() {
if(clicked){
$(this).attr("onclick","closeNav()");
clicked = false;
} else {
$(this).attr("onclick","openNav()");
clicked = true;
}
});
function openNav() {
document.getElementById("navbar_myside").style.width = "100px";
document.getElementById("wrapper").style.marginLeft = "100px";
//document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
}
function closeNav() {
document.getElementById("navbar_myside").style.width = "0";
document.getElementById("wrapper").style.marginLeft = "0";
//document.body.style.backgroundColor = "white";
}
obrigado.Discussão (6)
Carregando comentários...