这不是一个最好的语法问题(其他JS函数调用在同一页上工作得很好)。当我点击一个调用此函数的链接时,为什么没有发生?
它提出的第一个问题是,如果一个特定的DIV ID的显示属性设置为“无”(它确实),并且,如果是的话,它应该将其设置为“阻止”(以及其他一些事情),但绝对没有任何反应。我为另一个网站编写了函数,它在那里工作得很好,现在......什么都没有。我正在拉我的头发!在此先感谢...
function showHideFooter(FooterLinkP,FooterLinkSPAN)
{
var DIV = document.getElementById('FooterLinksContentDIV');
var P = document.getElementById(FooterLinkP);
var SPAN = document.getElementById(FooterLinkSPAN);
if (DIV.style.display == 'none')
{
DIV.style.display = 'block';
P.style.display = 'block';
SPAN.style.border = '1px solid #606060;';
SPAN.setAttribute('style','background: url("img/navlinkhoverbg.jpg")');
}
else if ((DIV.style.display == 'block') && (SPAN.style.border !== 'transparent'))
{
P.style.display = 'none';
DIV.style.display = 'none';
SPAN.style.background = 'transparent';
SPAN.style.border = 'transparent';
SPAN.setAttribute('style','background:hover:url("img/navlinkhoverbg.jpg")');
SPAN.setAttribute('style','border:hover: 1px solid #606060;');
}
else
{
var number = 1;
var contentArray = new Array();
contentArray[0] = '<? echo METHODS::footerPopulator(1,'title');?>';
contentArray[1] = '<? echo METHODS::footerPopulator(2,'title');?>';
contentArray[2] = '<? echo METHODS::footerPopulator(3,'title');?>';
contentArray[3] = '<? echo METHODS::footerPopulator(4,'title');?>';
contentArray[4] = '<? echo METHODS::footerPopulator(5,'title');?>';
contentArray[5] = '<? echo METHODS::footerPopulator(6,'title');?>';
contentArray[6] = '<? echo METHODS::footerPopulator(7,'title');?>';
contentArray[7] = '<? echo METHODS::footerPopulator(8,'title');?>';
contentArray[8] = '<? echo METHODS::footerPopulator(9,'title');?>';
for (section in contentArray)
{
document.getElementById(contentArray[section]).style.display = 'none';
while (number <= 9)
{
document.getElementById(number).style.background = 'transparent';
document.getElementById(number).style.border = 'transparent';
document.getElementById(number).setAttribute('style','background:hover:url("img/navlinkhoverbg.jpg")');
document.getElementById(number).setAttribute('style','border:hover: 1px solid #606060;');
number++;
}
}
P.style.display = 'block';
SPAN.style.border = '1px solid #606060;';
SPAN.setAttribute('style','background:url("img/navlinkhoverbg.jpg")');
}
}
UPDATE:
<SPAN class="FooterLinkSPAN" id="1">
<A href="#links" onclick="showHideFooter('<? echo METHODS::footerPopulator(1,'title'); ?>','1');" class="footerLinks"><? echo METHODS::footerPopulator(1,'title');?></A>
</SPAN>
放在一个警告if和else if语句得到什么,但放在else语句弹出,所以它的考虑前两个块是错误的......但他们不是。我不明白。但你们快回复!这个网站很棒!
你能后的标记吗? – 2012-02-18 22:27:11
调试器告诉你什么?另外,请发布“链接”标记/代码。 – Steve 2012-02-18 22:27:27
如果您向我们展示您的html,这可能会有所帮助。你已经设置了错误的JavaScript调用,因此函数不会被调用。 – 2012-02-18 22:27:58