所以我发现了一个脚本,可以很好地显示一个隐藏的div,只要点击我选择的另一个元素。但是,我希望这更像一个切换。谁能帮我吗?我试过尽我所能调整脚本,但jQuery并不是我的特长。jQuery - 点击隐藏我已经点击显示的元素
<script type="text/javascript">
(function($){
document.documentElement.className += " js"; // Add js class to the HTML element
$(function(){
var $containers = $("#repaircontent").hide();
jQuery(document).ready(function(){
/* Show the HTML page only after the js and css are completely loaded */
delayShow();
});
function delayShow() {
var secs = 1000;
setTimeout('jQuery("#repaircontent").css("visibility","visible");', secs);
}
$('#repairtab').each(function(i,el){
var idx = i;
$(this).click(function(e){
var $target = $containers.filter(':eq(' + idx + ')');
$target.not(':visible').fadeIn();
e.preventDefault();
})
})
})
})(jQuery);
</script>
有你,尽管使用切换的? http://api.jquery.com/toggle/ – Drakoumel 2013-03-08 14:47:38