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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -