I have a script that hides an element and its content and loads another element and its content on click. The strange thing is, it seems to pile up the 1px border and returns the second element with a 2px border, while showing it still has 1.
This is the link code:
<li ><a href="plumbing.php">Plumbing</a></li>
This is the element in question:
<div id="box1">
<ul class="tabs">
<li><a href="#" class="defaulttab" rel="tabs1">Tab #1</a></li>
<li><a href="#" rel="tabs2">Tab #2</a></li>
<li><a href="#" rel="tabs3">Tab #3</a></li>
</ul>
<div class="tab-content" id="tabs1">Tab #1 content</div>
<div class="tab-content" id="tabs2">Tab #2 content</div>
<div class="tab-content" id="tabs3">Tab #3 content</div>
</div>
Element that on the page that gets loaded is identical with the exception of having only 1 tab and 1 tab content (for the purpose of testing).
Style:
#box1{width:700px;height:100%;float:left;background:url(../images/box1bg_03.gif);background-repeat:repeat-x;border: 1px solid #d0ccc9;}
Javascript:
$(document).ready(function() {
var hash = window.location.hash.substr(1);
var href = $('.navcontent li a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href.length-5)){
var toLoad = hash+'.html #box1';
$('#box1').load(toLoad)
}
});
$('.navcontent li a').click(function(){
var toLoad = $(this).attr('href')+' #box1';
$('#box1').hide('fast',loadContent);
$('#load').remove();
$('#box1').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#box1').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#box1').show('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
});
In theory, everything works perfectly except the border - https://i.sstatic.net/qz7yk.jpg. Very annoying.