最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery lightbox does not load images - Stack Overflow

programmeradmin4浏览0评论

I am trying to get this lightbox to work and I'm not quite sure what I'm missing.

My relevant code is as follows:

<head>
    <link href="style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="jquery.js"></script>            
    <!-- Lightbox -->
    <script type="text/javascript" src="jquery.lightbox-0.5.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery.lightbox-0.5.css" media="screen" />

    <script type="text/javascript">
        $(document).ready(function() {        
            $("imgidas").lightBox();
        });

    </script>       
</head>

The images are displyed in this manner:

<tr>
    <td><a href="images/big-boss-adulto.jpg"><img src="images/big-boss-adulto.jpg" width="118" height="170" class="idas"/></a></td>
    <td><a href="#"><img src="images/big-boss-cachorro.jpg" width="118" height="170" class="idas"/></a></td>
    <td><a href="#"><img src="images/eukanuba-adulto.jpg" width="118" height="170" class="idas"/></a></td>
</tr>

(I'm only trying if the lightbox works on the first image)

The problem id the following, the lightbox gets stuck here (in the loading part):

Things I've checked and that I can infer:

  • All the js and css are correctly linked and exist
  • The javascript and styleshit of the lightbox are probable working correctly since:
    • The style seems to be the correct
    • When you click outside the image (or press esc) the lighbox disappears

Another thing I've checked was using load:

$(window).load(function() {       
    $("imgidas").lightBox();
});

But the same problem seems to persist.

I am trying to get this lightbox to work and I'm not quite sure what I'm missing.

My relevant code is as follows:

<head>
    <link href="style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="jquery.js"></script>            
    <!-- Lightbox -->
    <script type="text/javascript" src="jquery.lightbox-0.5.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery.lightbox-0.5.css" media="screen" />

    <script type="text/javascript">
        $(document).ready(function() {        
            $("img.idas").lightBox();
        });

    </script>       
</head>

The images are displyed in this manner:

<tr>
    <td><a href="images/big-boss-adulto.jpg"><img src="images/big-boss-adulto.jpg" width="118" height="170" class="idas"/></a></td>
    <td><a href="#"><img src="images/big-boss-cachorro.jpg" width="118" height="170" class="idas"/></a></td>
    <td><a href="#"><img src="images/eukanuba-adulto.jpg" width="118" height="170" class="idas"/></a></td>
</tr>

(I'm only trying if the lightbox works on the first image)

The problem id the following, the lightbox gets stuck here (in the loading part):

Things I've checked and that I can infer:

  • All the js and css are correctly linked and exist
  • The javascript and styleshit of the lightbox are probable working correctly since:
    • The style seems to be the correct
    • When you click outside the image (or press esc) the lighbox disappears

Another thing I've checked was using load:

$(window).load(function() {       
    $("img.idas").lightBox();
});

But the same problem seems to persist.

Share Improve this question edited Dec 15, 2011 at 5:14 Trufa asked Dec 15, 2011 at 4:56 TrufaTrufa 40.8k44 gold badges132 silver badges193 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Try selecting the containing <a> element, instead of the image itself, for the lightbox() function.

You are targeting the wrong element in your JS. You need to target the anchor link around the image, rather than the image itself.

发布评论

评论列表(0)

  1. 暂无评论