Hey all,
So I thought I was making significant progress refactoring some javascript tabs I initially created in pure javascript, but now resorted to jQuery. While I can get it to correctly display the right div container using $(displayDiv).show(); in the below code. The problem is I try to use the .empty() method to empty the outer content container so I can then display ONLY the specific div. However empty() empties the outer container and then fails to show the specific div I specify:
Code:
$(document).ready(function()
{
var linksToInt = {
"#pple": 0,
"#serv": 1,
"#sol": 2
}
/*
links = document.getElementsByTagName("a");
if(links.className.indexOf("div-link") > -1){
links.onclick = function{ removeHash(this.getAttribute("href"));};
}
*/
$("a.div-link").click(function(){displayDiv($(this).attr("href"));});
function displayDiv(id){
var linkInt = linksToInt[id];
on_btn_click(linkInt);
}
function on_btn_click(displayDiv){
displayDiv != null ? null : this;
switch(displayDiv){
case 0:
$("#content").empty();
$(displayDiv).show();
break;
case 1:
$("#content").empty();
$(displayDiv).show();
break;
case 2:
$("#content").empty();
$(displayDiv).show();
break;
case 3:
$("#content").empty();
$(displayDiv).show();
break;
}
}
});
Code:
<div id="content">
<div class="tabContent" id="pple">
<p>
Some Content.
</p>
</div>
<div class="tabContent" id="serv">
<p>
Some Content
</p>
</div>
<div class="tabContent" id="sol">
<p>
Some Content
</p>
</div>
</div>
Any suggestions? thanks.