Red de conocimiento informático - Material del sitio web - ¿Cómo escribir este evento html onclick()?

¿Cómo escribir este evento html onclick()?

& ltbody & gt

& ltdiv id = " txt " & gt

& ltinput type = " text "/& gt;& lt/div & gt;

& ltbr/>;

& ltipo de entrada = " botón " ID = " BTN " valor = " botón " valores = " 1 "/& gt;

& lt/ body & gt;

& ltscript type = " text/JavaScript " & gt;

Función click(){

var attr = document . ("BTN"). Atributo["valor"];

valor var = valor del atributo;

if (valor == "1") {

documento getelementbyid(" txt. ")estilo . display = " none ";

attr.value = " 2

}

else if (value == "2") {

documento. getelementbyid(" txt ")estilo .

}

}

window.onload=function(){

var BTN = document . getelementbyid(" BTN ");

onclick = función(. ){ clic();};

};

& lt/script & gt;