peggy peggy - 1 year ago 97
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.

Answer Source

You would use contents()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download