开发者

How to addClass to a body tag inside a generated iframe

开发者 https://www.devze.com 2023-02-01 00:00 出处:网络
I\'m using JQ Colorbox plug-in (a sort of Lightbox) and I\'d like to add a class to the body of a document loaded via Colorbox\'s iframe function.

I'm using JQ Colorbox plug-in (a sort of Lightbox) and I'd like to add a class to the body of a document loaded via Colorbox's iframe function.

Basically, I was trying to:

$("iframe").contents().find('body').addClass('foo');

but that doesn't seem to work, probably because my iframes are not generated until after a user invoke C开发者_运维问答olorbox?

Is there a way to achieve such result?

Many thanks.


The ColorBox documentation says that there are 4 event hooks you can use. For example (lifted from their examples page);

$("#myColorBox").colorbox({
    onComplete: function(){
        alert('onComplete: colorbox has displayed the loaded content');
    }
});
0

精彩评论

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