peggy peggy - 21 days ago 7x
HTML Question

Jquery iterate through html elements in iframe

I currently have refactored some code and am getting hung up on some jquery usage. Before, I was using a jquery

loop and iterating through dom elements like this:

$.each($('[id*="cnv"]'), function (index, value) { /*do work*/ }

and this will select each element who's ID contains
. Now I have moved the code and need to iterate through these elements but from outside the iframe that they live in. I access these elements in various places using javascript as follows

var canvasObj = window.frames['iframe'].contentDocument.getElementById(canvasId);

is the id/name of my iframe) but I am not sure how to combine these two statements so that I can iterate through elements with matching ids from a parent.


You would use contents()