0
我對揭示div的基於其ID的解決方案,但我想它淡入巢jQuery的內部JavaScript函數淡入事業部從顯示:無
由於頁面和複雜性。事實上它是在WordPress內部我想修改這個DOM函數來包含一個.show(「slow」)來使淡入淡出工作與重新設計整個頁面。
下面是代碼:
CSS座
<style>
.biobox { display:none;}
</style>
的JavaScript,我想插入jQuery的進入要淡入 VAR的div = [ 「一」, 「二」]; var visibleDivId = null;
function toggleVisibility(divId) {
if(visibleDivId === divId) {
visibleDivId = null;
} else {
visibleDivId = divId;
}
hideNonVisibleDivs();
}
function hideNonVisibleDivs() {
var i, divId, div;
for(i = 0; i < divs.length; i++) {
divId = divs[i];
div = document.getElementById(divId);
if(visibleDivId === divId) {
div.style.display = "block";
//the above line I want to swap with a jquery instance that includes .show("slow"), such as this code that does not work for me $(document).ready(function(){ $(div).show("slow"); });
} else {
div.style.display = "none";
}
}
}
</script>
DIV的是隱藏在默認情況下
<div class="biobox" id="one">
<img src="http://deliveringhappiness.com/wp-content/uploads/2013/08/thought-leadership1.jpg" width="346" height="346" border="0" />
</div>
<div class="biobox" id="two">
<img src="http://www.traianbadulescu.ro/wp-content/uploads/2012/10/leaders.jpg" width="402" height="317" />
</div>
代碼來切換DIV能見度生物盒中
<a href="#" onclick="toggleVisibility('one');">Close</a>
<a href="#" onclick="toggleVisibility('two');">Close</a>
那麼,如何來$(document).ready(function(){ $(div).show("slow"); });
不代替div.style.display = "block";
工作?順便說一句我在此代碼之前將jQuery插入頁面。
是的,我知道我可以通過兩個類來實現,一個是display:none和另一個是不透明的,使用jQuery的淡入命令,但是我發現的代碼全部寫在jQuery中,我不知道如何把它與這個非jQuery代碼整合起來,但我會在明天發佈它。 感謝您確認您無法從顯示中淡出:無。這關閉了一些可能的解決方案。 – ComputerGiant
你的jQuery做這樣的事情可能就像'element.toggleClass('showing');'你可以(或應該)在CSS中做的其他事情。 – Matijs