请问我做的这个按钮为什么需要点击两次才能激活呢
#smile_bg{margin:0; padding:0; background:url(images/smile_bg.gif) no-repeat;width:435px; height:304px; margin-top:-5px; display:none;}function smile_Swich() { if (GetByID('smile_bg').style.display == 'none') { GetByID('smile_bg').style.display = 'block'; } else { GetByID('smile_bg').style.display = 'none'; }}function GetByID(str) { var v = document.getElementById(str); return v;}<img src="images/111.gif" onclick="smile_Swich()" />
if (GetByID('smile_bg').style.display != 'block') {/////改成这样判断就好了 GetByID('smile_bg').style.display = 'block'; } else { GetByID('smile_bg').style.display = 'none'; }