这是一个小问题。
http://jsfiddle.net/fkling/TpF24/ 在此示例中,我需要默认打开
我该怎么做?
就是这样,非常感谢! :D
JS代码:
var current = null;
function showresponddiv(messagedivid){
var id = messagedivid.replace("message-", "respond-"),
div = document.getElementById(id);
// hide previous one
if(current && current != div) {
current.style.display = 'none';
}
if (div.style.display=="none"){
div.style.display="inline";
current = div;
}
else {
div.style.display="none";
}
}
最佳答案
移除 HTML 中默认的 display: none
。演示:jslint .
或者正如 Gaby 建议的那样,通过在 windiw.load
上调用 showrespondiv('message-1')
来使用 javascript 隐藏 div。
关于javascript - 制作默认DIV(JS代码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12965271/