js中 document.getElementById().styl.display的问题

2025-02-02 02:33:50
推荐回答(4个)
回答1:

document.getElementById().styl.display='none'
getElementById()不显示。
document.getElementById().styl.display=''
getElementById()就显示出来

回答2:

document.getElementById().styl.display='none'
getElementById()不显示。
document.getElementById().styl.display=''
getElementById()就显示出来。
进入页面时,所有的"shops_"+id为标识的全部不显示,即sytle.display='none';
传入值时,显示相对应id的element,即将style.display='',并保存此id于页面里面一个隐藏的input里边。当下一次有值传入时,先看看那个隐藏的input中值,并将对应的那个id的style.display='none';

具体程序:
function init()//body的onload执行
{
for(var i=1;i<100;i++)//默认100个element,可调
document.getElementById('shops_'+i).style.displa='none';
}

function showFoodsMore(id)
{
var lastid=document.getElementById('lastid').value;
if(lastid)document.getElementById("shops_"+lastid).style.display='none';
else
{
var ctrl = document.getElementById("shops_"+id)
if(ctrl == null) return;
if(ctrl.style.display == "none")
{
ctrl.style.display = "";
}
document.getElementById('lastid').value=id;
}
}

回答3:

我的思路:

1.进入页面时,所有的"shops_"+id为标识的全部不显示,即sytle.display='none';
2.传入值时,显示相对应id的element,即将style.display='',并保存此id于页面里面一个隐藏的input里边
3.当下一次有值传入时,先看看那个隐藏的input中值,并将对应的那个id的style.display='none';

具体程序:
function init()//body的onload执行
{
for(var i=1;i<100;i++)//默认100个element,可调
document.getElementById('shops_'+i).style.displa='none';
}

function showFoodsMore(id)
{
var lastid=document.getElementById('lastid').value;
if(lastid)document.getElementById("shops_"+lastid).style.display='none';
else
{
var ctrl = document.getElementById("shops_"+id)
if(ctrl == null) return;
if(ctrl.style.display == "none")
{
ctrl.style.display = "";
}
document.getElementById('lastid').value=id;
}
}

前提你的页面里需要设置一个的元素

回答4:

捏哈哈,楼上的不对,,我来告诉你,,76928012