Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 打开并在lightbox中显示图像_Javascript_Jquery_Html_Css_Jquery Ui - Fatal编程技术网

Javascript 打开并在lightbox中显示图像

Javascript 打开并在lightbox中显示图像,javascript,jquery,html,css,jquery-ui,Javascript,Jquery,Html,Css,Jquery Ui,我在试着用prettypto lib。当有人在我的视图上单击一个图像时,屏幕会打开lightbox,并以一种良好的方式显示它 我从Stephane Caron的github资源中添加了prettypto.css和prettypto.js文件 我添加了它们的引用,做了一些标记和jquery代码 $(文档).ready(函数(){ $([rel^='prettypto[Gallery1]'])。prettypto({ 允许调整大小:false, 允许扩展:false, 显示标题:正确, 动画

我在试着用prettypto lib。当有人在我的视图上单击一个图像时,屏幕会打开lightbox,并以一种良好的方式显示它

我从Stephane Caron的github资源中添加了prettypto.css和prettypto.js文件

我添加了它们的引用,做了一些标记和jquery代码




$(文档).ready(函数(){
$([rel^='prettypto[Gallery1]'])。prettypto({
允许调整大小:false,
允许扩展:false,
显示标题:正确,
动画速度:“正常”,
幻灯片放映:7000,
主题:“pp_默认值”,
模态:假
});
});

如果我单击照片,而不是打开灯箱,则图像将在下一个选项卡中打开。

按F12键,您将看到控制台正在打开,请在I@novel ok中查找任何错误。它说:prettypto()不是一个函数。在这一行中-->$([rel^='prettypto[Gallery1]'])。prettypto({@vinodivinosteriano这一错误表明您的库没有加载,因此,
prettypto()
找不到。您没有包含完整的示例。请查看您的示例,并在需要时进行编辑。@VinoDivinoOsteriano正如Twisty正确建议的那样,您的prettypto.js没有加载。您应该检查路径,但为了快速测试,或者如果您仍然无法使其工作,您可以尝试CDN hi。它现在可以工作了。我更改了两件事。首先将jquery代码块放在“document.ready”中,然后-我显式地将ref添加到jquery文件中,尽管我在bundleConfig中添加了ref,因为这是我正在处理的一个MVC项目。奇怪的是,它应该从bundle本身中提取ref。但是,似乎我必须显式地“硬链接”jquery文件以实现此目的工作。按F12键您应该会看到控制台正在打开,在ITI@novel OK中查找任何错误。它说:prettypto()不是一个函数。在这一行-->$([rel^='prettypto[Gallery1]'])。prettypto({@vinodivinosteriano这一错误表明您的库没有加载,因此出现
prettypto()
找不到。您没有包含完整的示例。请查看您的示例,并在需要时进行编辑。@VinoDivinoOsteriano正如Twisty正确建议的那样,您的prettypto.js没有加载。您应该检查路径,但为了快速测试,或者如果您仍然无法使其工作,您可以尝试CDN hi。它现在可以工作了。我更改了两件事。首先将jquery代码块放在“document.ready”中,然后-我显式地将ref添加到jquery文件中,尽管我在bundleConfig中添加了ref,因为这是我正在处理的一个MVC项目。奇怪的是,它应该从bundle本身中提取ref。但是,似乎我必须显式地“硬链接”jquery文件以实现此目的工作
<div class="item col-md-4 col-sm-4 col-xs-12 moments everyday others festivals isotope-item" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1;">
            <a href="~/Resources/Images/ArtPreview/an eventful winter.jpg" class="vlightbox2" data-rel="" rel="prettyPhoto[Gallery1]">
                <img src="~/Resources/Images/ArtPreview/an eventful winter.jpg" alt="">
                <div class="caption">
                    <div class="info">
                        <h4></h4>
                        <div class="separator"></div>
                        <p></p>
                    </div>
                </div>
                <div class="vlb_zoom" style="position: absolute; display: none;"></div>
            </a>
        </div>
        <div class="item col-md-4 col-sm-4 col-xs-12 moments everyday others nature isotope-item" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1;">
            <a href="~/Resources/Images/ArtPreview/rebellion.png" class="vlightbox2" data-rel="" rel="prettyPhoto[Gallery1]">
                <img src="~/Resources/Images/ArtPreview/rebellion.png" alt="">
                <div class="caption">
                    <div class="info">
                        <h4></h4>
                        <div class="separator"></div>
                        <p></p>
                    </div>
                </div>
                <div class="vlb_zoom" style="position: absolute; display: none;"></div>
            </a>
        </div>
        <div class="item col-md-4 col-sm-4 col-xs-12 moments others nature isotope-item" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1;">
            <a href="~/Resources/Images/ArtPreview/Bulleh.jpg" class="vlightbox2" data-rel="" rel="prettyPhoto[Gallery1]">
                <img src="~/Resources/Images/ArtPreview/Bulleh.jpg" alt="">
                <div class="caption">
                    <div class="info">
                        <h4></h4>
                        <div class="separator"></div>
                        <p></p>
                    </div>
                </div>
                <div class="vlb_zoom" style="position: absolute; display: none;"></div>
            </a>
        </div>
        <div class="item col-md-4 col-sm-4 col-xs-12 moments others travel everyday nature isotope-item" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1;">
            <a href="~/Resources/Images/ArtPreview/with Love (2).jpg" class="vlightbox2" data-rel="" rel="prettyPhoto[Gallery1]">
                <img src="~/Resources/Images/ArtPreview/with Love (2).jpg" alt="">
                <div class="caption">
                    <div class="info">
                        <h4></h4>
                        <div class="separator"></div>
                        <p></p>
                    </div>
                </div>
                <div class="vlb_zoom" style="position: absolute; display: none;"></div>
            </a>
        </div>
        <div class="item col-md-4 col-sm-4 col-xs-12 moments everyday animal others isotope-item" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1;">
            <a href="~/Resources/Images/ArtPreview/Hannibal 4.jpg" class="vlightbox2" data-rel="" rel="prettyPhoto[Gallery1]">
                <img src="~/Resources/Images/ArtPreview/Hannibal 4.jpg" alt="">
                <div class="caption">
                    <div class="info">
                        <h4></h4>
                        <div class="separator"></div>
                        <p></p>
                    </div>
                </div>
                <div class="vlb_zoom" style="position: absolute; display: none;"></div>
            </a>
        </div>
        <div class="item col-md-4 col-sm-4 col-xs-12 moments travel nature everyday isotope-item" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1;">
            <a href="~/Resources/Images/ArtPreview/smplArt (2).jpg" class="vlightbox2" data-rel="" rel="prettyPhoto[Gallery1]">
                <img src="~/Resources/Images/ArtPreview/smplArt (2).jpg" alt="">
                <div class="caption">
                    <div class="info">
                        <h4></h4>
                        <div class="separator"></div>
                        <p></p>
                    </div>
                </div>
                <div class="vlb_zoom" style="position: absolute; display: none;"></div>
            </a>
        </div>


$(document).ready(function () {
    $("a[rel^='prettyPhoto[Gallery1]']").prettyPhoto({
    allow_resize: false, 
    allow_expand: false,
    show_title: true,
    animation_speed: 'normal',
    slideshow: 7000,
    theme: 'pp_default',
    modal: false
});

});