Fade out/in sperate divs with button click [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-14 03:37:09

问题


I saw a flash website and was curious to now if this is something possible to build using Jquery, obviously not the entire thing. I was more looking to fade out div1 and div2 with a button click. This is the example site: www.justinfarrellyconstruction.com

Example: If i come to the homepage and click the portfolio button the Gallery Div will fade out then fade in another image. At the same time the Text div will fade out its content and load the portfolio text.

My apologies if this does not make sense, this is all quite new to me and im trying got learn.


回答1:


Your question is very vague, but hopefully this example will get you started in the right direction: http://jsfiddle.net/3mJ3z/

Basically, there are 3 menu items, and 3 corresponding content items. When you click the menu item, all the other content items disappears and the corresponding content item fades in. The HTML:

<div class="item-1 content-item">
    I am the content for item 1
</div>

<div class="item-2 content-item" style="display: none;">
    I am the content for item 2
</div>

<div class="item-3 content-item" style="display: none;">
    I am the content for item 3
</div>

<ul>
    <li class="change-item" data-item="1">Item 1</li>
    <li class="change-item" data-item="2">Item 1</li>
    <li class="change-item" data-item="3">Item 1</li>
</ul>
​

The JS:

$('.change-item').click(function(){
    var this_item = $(this).attr("data-item");
    $('.content-item').hide();
    $('.item-' + this_item).fadeIn();
});​


来源:https://stackoverflow.com/questions/13942811/fade-out-in-sperate-divs-with-button-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!