Div赢得't单击时显示

Div won't show on click

本文关键字:单击 显示 赢得 Div      更新时间:2023-09-26

在此页面上:http://themejulies.tumblr.com

我左边有一个信息图标。我希望用户能够点击它,并显示一个包含信息的div。

我正在尝试实现这个,但它对我不起作用。这是我的代码:

HTML

 <div class="site-wrapper">
    {block:ifShowInfoButton}
     <a class="show_hide" href="#" rel="#slidingDiv"><i class="fa  fa-info-circle fa-3x" style="position:absolute; margin-left:0.4%; margin-top:0.4%; color:{color:Info Button Color};"></i></a>
     <div id="slidingDiv" class="toggleDiv" style="display: none;">Fill this space with really interesting content.</div>{/block:ifShowInfoButton}

jQuery

 <script type="text/javscript">
        (function ($) {
    $.fn.showHide = function (options) {
    //default vars for the plugin
        var defaults = {
            speed: 1000,
            easing: '',
            changeText: 0,
            showText: 'Show',
            hideText: 'Hide'
        };
        var options = $.extend(defaults, options);
        $(this).click(function () {
// optionally add the class .toggleDiv to each div you want to automatically close
                      $('.toggleDiv').slideUp(options.speed, options.easing);
             // this var stores which button you've clicked
             var toggleClick = $(this);
             // this reads the rel attribute of the button to determine which div id to toggle
             var toggleDiv = $(this).attr('rel');
             // here we toggle show/hide the correct div at the right speed and using which easing effect
             $(toggleDiv).slideToggle(options.speed, options.easing, function() {
             // this only fires once the animation is completed
             if(options.changeText==1){
             $(toggleDiv).is(":visible") ? toggleClick.text(options.hideText) : toggleClick.text(options.showText);
             }
              });
          return false;
        });
    };
})(jQuery);</script>

任何帮助都将是美妙的。非常感谢。

您必须使用插件来执行此任务,
转到此链接http://dimsemenov.com/plugins/magnific-popup/
下载并使用该插件,您还可以通过谷歌搜索找到其他插件
通过插件的这个任务对你来说变得非常容易。