javascript - prettyphoto undefined is not a function - Stack Overflow

I'm attempting to install prettyPhoto lightbox on my site and I keep getting them same error. The

I'm attempting to install prettyPhoto lightbox on my site and I keep getting them same error. The following code in the console generates this error

"undefined is not a function"

    <script type="text/javascript" charset="utf-8">
      $(document).ready(function(){
        $("a[rel^='prettyPhoto']").prettyPhoto();
      });
    </script>

Line 18

I've tried it in the footer and the head, both cause the same problem and the lightbox doesn't load.

Here's the files in my head tag...

<script src=".9.0/jquery.min.js" type="text/javascript"></script>
    <script src="//ajax.googleapis/ajax/libs/jquery/1/jquery.min.js"></script>
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
    <script src="<?php bloginfo('template_directory'); ?>/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

My site is www.jessicadraws

Any ideas?

Dave.

I'm attempting to install prettyPhoto lightbox on my site and I keep getting them same error. The following code in the console generates this error

"undefined is not a function"

    <script type="text/javascript" charset="utf-8">
      $(document).ready(function(){
        $("a[rel^='prettyPhoto']").prettyPhoto();
      });
    </script>

Line 18

I've tried it in the footer and the head, both cause the same problem and the lightbox doesn't load.

Here's the files in my head tag...

<script src="https://ajax.googleapis./ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
    <script src="//ajax.googleapis./ajax/libs/jquery/1/jquery.min.js"></script>
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
    <script src="<?php bloginfo('template_directory'); ?>/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

My site is www.jessicadraws.

Any ideas?

Dave.

Share Improve this question edited Feb 11, 2015 at 10:57 Dave Morgan asked Feb 11, 2015 at 10:40 Dave MorganDave Morgan 211 gold badge2 silver badges6 bronze badges 3
  • btw, did you include prettyPhoto js ..? – Sudhir Bastakoti Commented Feb 11, 2015 at 10:43
  • Seems like it can't find the prettyPhoto.js file, then the prettyPhoto() function is undefined. Where are you including the prettyPhoto script? – Kangcor Commented Feb 11, 2015 at 10:43
  • It's included in the head tag <script src="<?php bloginfo('template_directory'); ?>/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script> – Dave Morgan Commented Feb 11, 2015 at 10:45
Add a ment  | 

1 Answer 1

Reset to default 2

Your page loads 3 versions of jQuery. This is likely causing issues with other plugins. Pretty Photo is loading fine - it's just loading onto jQuery 1.9

I can see this by running this in the devtools:

var jquery162 = $.noConflict(true);
> undefined
$.fn.jquery
> "1.9.0"
$.prettyPhoto
> Object {version: "3.1.5"}

To fix this won't be simple unfortunately, you'll need to decide which version of jQuery you are using and stop loading the rest.

For reference in <head> you are loading:

<script src="//ajax.googleapis./ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://ajax.googleapis./ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>

PrettyPhoto is loaded just after these, in the head.

In your <body>:

<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.6.2/jquery.min.js"></script>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745638513a4637544.html

相关推荐

  • javascript - prettyphoto undefined is not a function - Stack Overflow

    I'm attempting to install prettyPhoto lightbox on my site and I keep getting them same error. The

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信