javascript - getting the contents of a div tag with class -
javascript - getting the contents of a div tag with class -
i trying read particular contents of kid iframe wrapped in div tag parent window. using
detailsvalue = window.frames['myiframe'].document.getelementbyid('result').innerhtml;
with i'm able access entire content of frame. need access portion of content. problem div wraps content looking contains class , no id.
<div class="watineed"> <table class="details"> </table> </div>
i unable access content in form of table (with no id , class).
any help.
edit1: need access content of table check char length , html tags nowadays in content.
you can either using plain javascript (as mentioned notulysses):
window.frames['myiframe'].document.queryselector('.watineed .details')
or using jquery (since aded jquery) specifying iframe's document
context $
:
$(".watineed .details", window.frames['myiframe'].document)
in latter case you've fullfeatured jquery object.
note in either case iframe's document has on same domain otherwise you'd run cross origin issues.
tested against jquery 2.0.x
updateif you're running selector during page load of including page, you'll have hear load
event of iframe before accessing content:
$(window.frames['myiframe']).on("load", function(){ // above query here });
javascript jquery iframe
Comments
Post a Comment