I need to put jQuery in "mypage.htm". I use a light b...">

Using jquery on a child page

if i load ('mypage.htm') in <div id="placeMyContentHere">

I need to put jQuery in "mypage.htm". I use a light box ike on my child page. If I add jquery.js and colorbox.js to mypage.htm, this will work. Although I can not help thinking that there is a better way.

This is how I usually call colorbox

$(document).ready(function() {

$("a[rel='example1']").colorbox();
+3
source share
3 answers

Use the callback function loadto reinitialize the colorbox, there is no need for $(document).ready(...the content that you enter into yours div, for example:

$("#placeMyContentHere").load('mypage.htm', function() {
    $("a[rel='example1']").colorbox();
});
+2
source

jquery colorbox . DOM, jquery live

$("a[rel='example1']").live(function(){
   $(this).colorbox();
});
+1

, javascript- (jQuery ) ; .

0

Source: https://habr.com/ru/post/1730207/


All Articles