简体   繁体   English

显示此div并隐藏该div

[英]Show this div and hide that div

Hello i want to know how can i modify my following js function to hide the content of one div and shows the content of the following div in the opened popup of fancybox the following div to show 您好,我想知道如何修改以下js函数以隐藏一个div的内容,并在打开的fancybox弹出窗口中显示以下div的内容,以显示以下div

<LI><A class="demo" id="example4" href="#demoView">Demo</A></LI> //linkfunctionality i want to show
<a id="various2" href="#divVideo" class="fl ml20"><img src="images/sites/img2.png" alt="" class="fl mr10" /></a> //Link functionality i want to hidde

<div style="display:none;">
    <div id="demoView">
        <div class="fl w900 pa20 bg2 tac">
            <h3 class="ff2 fwb fs30 mb10 cf3">Please contact us for a quick demo.</h3>
            <h4 class="ff2 fwb fs26 mb40 cf3">Email: <span  class="cf2 pr25"><a style="text-decoration:none; color:#2a98e2;" href="mailto:info@caremerge.com">info@caremerge.com</a></span> Call: <span class="cf2">(888) 996 6993</span></h4>
            <img src="images/sites/demo1.png" alt=""  class="dpib mb20"/>
        </div>
    </div>
</div>

The function below is successfully hiding the video but its not displaying the div mentioned above in it... 以下功能已成功隐藏了视频,但未在其中显示上面提到的div ...

 function onPause() {

       froogaloop.addEvent('pause', function(data) {
                //$('a[href="#various2"]').fadeOut();
                $('#divVideo').fadeOut(500);
                // $('#various2').fadeOut(500);
                //$(' #demoView').fadeIn(500);
                $('#demoView').fadeIn();

                alert('ST-UCK');

       });
 }

Some part of FANCY BOX JQUERY OF MY CODE FANCY BOX JQUERY OF MY CODE的某些部分

jQuery(document).ready(function() {     

        $("a#example4").fancybox({
                'opacity'       : true,
                'overlayShow'   : false,
                'transitionIn'  : 'elastic',
                'transitionOut' : 'none'
            });

        $("#various2").fancybox({
            'opacity'       : true,
                'overlayShow'   : false,
                'transitionIn'  : 'elastic',
                'transitionOut' : 'none',
                'onClosed'  :   function() {
                            document.getElementById('iframe-video');

                },
                'onStart'       :   function() {
                            //alert("hi");
                            //$('#banner-rotator').royalSlider({slideshowEnabled:false,slideshowDelay:20000 });
                }
        });

When you open inline content in fancybox (either #demoView or #divVideo as in your example) the content is literally moved from its place in the html flow into the fancybox and a temporary div is left instead. 当您在fancybox中打开内联内容(如您的示例中的#demoView#divVideo )时,内容实际上从html流中的位置移至fancybox中,而是保留了一个临时div

So when you opened #divVideo in fancybox, only that content is actually inside fancybox so this is why you can fade it out. 因此,当您在fancybox中打开#divVideo时,实际上只有该内容在fancybox中,因此这就是您可以淡出它的原因。 You cannot fade #demoView in because it doesn't exist inside fancybox. 您无法淡入#demoView ,因为fancybox中不存在它。

Maybe you just need to trigger the second fancybox inside your (pause) event callback like 也许您只需要在(暂停)事件回调中触发第二个fancybox

function onPause() {
       froogaloop.addEvent('pause', function(data) {
                $('#example4').trigger("click"); //linkfunctionality you want to show
       });
 }

... that will bring the second content ( #demoView ) inside fancybox and the current ( #divVideo ) will just fade out. ...这会将第二个内容( #demoView#demoView fancybox中,而当前内容( #divVideo )将淡出。

Is it now because the enclosing div for demoView is hidden? 现在是因为包围demoView的 div被隐藏了吗? So something like... 所以像...

$("#demoview").parent().css({'display','inherit'});

May work? 可以工作吗?

Why is the parent even there? 为什么父母在那里? Perhaps you should do away with it and put the style attribute on your demoView div. 也许您应该删除它,并将style属性放在demoView div上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM