I am using a JavaScript function and some jQuery to do two things on a page. The first is a simple JS function to hide / show the div and change the active state of the tab:
This is JS that shows / hides the div and changes the active state on some tabs:
var ids=new Array('section1','section2','section3');
function switchid(id, el){
hideallids();
showdiv(id);
var li = el.parentNode.parentNode.childNodes[0];
while (li) {
if (!li.tagName || li.tagName.toLowerCase() != "li")
li = li.nextSibling;
if (li) {
li.className = "";
li = li.nextSibling;
}
}
el.parentNode.className = "active";
}
function hideallids(){
for (var i=0;i<ids.length;i++){
hidediv(ids[i]);
}
}
function hidediv(id) {
document.getElementById(id).style.display = 'none';
}
function showdiv(id) {
document.getElementById(id).style.display = 'block';
}
html:
<ul>
<li class="active"><a onclick="switchid('section1', this);return false;">ONE</a></li>
<li><a onclick="switchid('section2', this);return false;">TWO</a></li>
<li><a onclick="switchid('section3', this);return false;">THREE</a></li>
</ul>
<div id="section1" style="display:block;">TEST</div>
<div id="section2" style="display:none;">TEST 2</div>
<div id="section3" style="display:none;">TEST 3</div>
Now the problem is ....
I added a jQuery image gallery called galleria to one of the tabs. The gallery works great when it is in a div that is intuitively configured to display: block. However, when it is in one of the divs that is set to display: none; part of the gallery does not work when the div switches to visibility. In particular, the following css stops writing (this is created by galleria jQuery):
element.style {
display:block;
height:50px;
margin-left:-17px;
width:auto;
}
, , div : none. ( Javascript), ? , , : block; .
? , - jQuery... , , , ?
!