jquery - How do I check if an element exists inside an iframe? -
$('#frame').load(function(){ settimeout(function() { alert($("#frame a[href=check]").length); },2000); });
the alert
shows 0
, iframe loads correctly , link exists.
to fetch contents of iframe try
$('#frame').load(function () { settimeout(function () { alert($('#frame').contents().find('a[href=check]').length); }, 2000); });
the .contents() method can used content document of iframe, if iframe on same domain main page.
Comments
Post a Comment