jquery - Attaching events to images inside iframe -
i have iframe (with id=iframe) , trying attach onclick event each one. iframe within domain.
$("#iframe").contents().find('img').each(function () { $(this).on('click', function (event) { $('#image-box', window.parent.document).show(300); window.parent.document.getimage(this); }); });
thanks in advance
i had load iframe first otherwise wouldn't work. solution, therefore, looks this:
var iframe = $("#iframe"); iframe.load(function () { iframe.contents().find('img').each(function () { $(this).on('click', function (event) { $('#image-box', window.parent.show(300)); window.parent.getimage(this); }); }); });
Comments
Post a Comment