开发者

Why won't this jQuery include work?

开发者 https://www.devze.com 2023-02-27 18:28 出处:网络
I have a modal window from which I am calling a lighbox to view images. I have got the lightbox to work on it\'s own, but cannot get it working from the modal window.

I have a modal window from which I am calling a lighbox to view images. I have got the lightbox to work on it's own, but cannot get it working from the modal window.

If i include jQuery before the lightbox includes - the page breaks and all styling of the portlet fails.

Any help greatly appreciated, Rich.

Project: http://djrb.co.uk/lightbox/tester.html

Working example of lightbox: http://djrb.co.uk/lightbox/working_exa开发者_运维问答mple.html


Looks like you are including both jQuery and Prototype. Since they both redefine the $ you need to do special handling and have the following line after jQuery is loaded

  jQuery.noConflict();

See this link for more details.


You have other JS libraries already included. These libraries are accessed via $, the same way jquery is. If you have to use mutiple libraries use jquery no conflict mode.

<html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();

     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });

     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>
0

精彩评论

暂无评论...
验证码 换一张
取 消