<A HREF="javascript:showHide('div6')">SECTION TITLE</a></font>
<div id="div6" style="display:none;">
This text will become visible when section title is clicked.
</div>
However, I get strange behavior when the above DIV is located within an AJAX response. My main page loads another HTML page into a div, and within THAT div is the "div6" above.
document.getElementById(elementid) returns "div6", and document.getElementById(elementid).style.display returns "none", as expected.
However, the set command is ignored. Nothing happens:
document.getElementById(elementid).style.display = '';
BUT, if I do an alert after the set, the element returns display as "".
So it's setting the element, but style.display is having no visible effect on the actual element.
I do not know for certain, but I suspect your 'showHide()' function is being fired before the new 'div6' has been incorporated within the DOM tree. There isn't enough code here to tell.
Once again--there isn't enough of your code posted here to do much more than speculate.
Could it be for example that your function is working on the currently existing 'div6' but THEN the AJAX response comes replacing it with contents that set the inline style display property to "none?"
And is your AJAX request made asynchronously or not? That too could make a big difference.
Bookmarks