jquery accessing children() value (using .html()) -
i have webpage - clicking button - dynamically create iframe holds editable text field (cke editor). need access edited text when 1 clicks button (that html() send sqlite db later etc.).
this html (inside php file) structure iframe part onward (this actual generated html text - copied firebug extension firefox - tho simplified me purpose):
<iframe class="cke_wysiwyg_frame cke_reset"> <!doctype html> <html lang="sk" dir="ltr"> <head>//some other tags here...not important problem</head> <body class="cke_editable cke_editable_themed cke_contents_ltr> //some editable text here...this need access! </body> </html> </iframe>
i have jquery code trying access body html value created dynamically once again php (as guess tried every possible way have found stripped down testing purposes alert() see if gives me value or not):
echo 'alert(jquery("iframe[class*=\'cke_wysiwyg_frame\']").children("html").children("body").html());';
when use "null" in alert() window tho first part jquery("iframe[class*=\'cke_wysiwyg_frame\']") works ok - tested, finds right iframe...
so desperate tryed several other ways these once below according other stackowerflow topic have found:
echo 'alert(jquery("iframe[class*=\'cke_wysiwyg_frame\']").children().eq(0).children().eq(1).html());'; // ok know get() giving dom object , should nested in other jquery(), anyway... echo 'alert(jquery("iframe[class*=\'cke_wysiwyg_frame\']").children().get(0).children().get(1).html());'; echo 'alert(jquery("iframe[class*=\'cke_wysiwyg_frame\']").find("body").html());';
all of giving me "null" of "undefined" in alert() test window. reason not able access children() object, or @ least not know functional way how access it/them (cos according alert() window when had (jquery("iframe[class*=\'cke_wysiwyg_frame\']").children() gives me [object object] that's - there no way know access move next children()).
i search web relevant answers pointing stackowerflow tho none of them work me.
what do wrong here? have no clue...unfortunately.
edit @a. wolff answer right 1 - please, can post answer standalone message can flag right answer?
<html> <body> <p id="demo" onclick="myfunction()">click me change html content (innerhtml).</p> <script> function myfunction() { document.getelementbyid("demo").innerhtml = "paragraph changed!"; } </script> </body> </html>
Comments
Post a Comment