Question

I want to insert one object like $('<p>Test</p>').prependTo('#TB_window'); just whenever #TB_window object is created.

How it can be made after the creation of a thickbox?

I want to use that in the wordpress site http://hogdal.dk/?p=60

Just see the pictures in the gallery.

I am using wordpress default thickbox.

Was it helpful?

Solution

How about this:

http://jsfiddle.net/zerkms/YZwRu/

$(document).on('DOMNodeInserted', function(event) {
    var $target = $(event.target);

    if ($target.is('#TB_window')) {
        $target.append('<p>Test</p>');
    }
});

$('body').append('<p>a</p>');
$('body').append('<p id="TB_window">b</p>');
$('body').append('<p>c</p>');
​

In this example we use DOMNodeInserted event, which is triggered when another node is inserted into document. After that we check if that element has the required id, and if so - append new node to it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top