I am trying to grab the content of a div from within an iframe. I have the following code:
$('iframe').load(function() {
setTimeout(function() {
content = $("iframe").contents().find("div#totaltime").html();
alert(content);
}, 800);
});
My alert message says "undefined" and yet when I remove the ".html()" I get an alert saying "[object Object]" ... any ideas how to extract the contents of this div. There should just be a time in the div like "1:33" but when I run .text() instead of .html() I just get a blank alert.
This is the html from inside the iframe:
<div id="totaltime" class="item graytext" style="visibility: visible; left: 368px; top: 51px; width: 32px; height: 16px; font-size: 11px; font-family: Arial;">06:44</div>
Thanks!
UPDATE
Ok, I've changed to:
$(window).load(function() {
setTimeout(function() {
content = $("iframe").html();
alert(content);
}, 800);
});
Now I just get a blank alert box.