js中 document.getElementById(show_div).style.display=✀block✀; 什么意思

2025-05-14 14:27:14
推荐回答(1个)
回答1:

//定义一个名为ShowDiv的方法,里面有2个参数
function ShowDiv(show_div, bg_div) {
   // 设置id是show_div参数值的元素为可见
    document.getElementById(show_div).style.display = 'block';
   // 设置id是bg_div参数值的元素为可见
    document.getElementById(bg_div).style.display = 'block';
   // 获取id是bg_div参数值的元素
    var bgdiv = document.getElementById(bg_div);
   // 设置它的宽度为body元素的宽度
    bgdiv.style.width = document.body.scrollWidth;
   // 设置id是bg_div参数值的高度为文档的高度
    $("#" + bg_div).height($(document).height());
}
//定义一个名为CloseDiv的方法,里面有2个参数
function CloseDiv(show_div, bg_div) {
   // 设置id是show_div参数值的元素为不可见
    document.getElementById(show_div).style.display = 'none';
   // 设置id是bg_div参数值的元素为不可见
    document.getElementById(bg_div).style.display = 'none';
}
// 即用了jquery的方法,又用了原始javascript的方法
// 非常有个性
// 费心劳力,采纳即可。