I use a jquery plugin for generating rich text editor. That editor generates an structure like this:
<div id="editor" ... >
...
<iframe>
<!DOCTYPE html>
<html>
<head>...</head>
<body>
//some important content here and I need to get them
</body>
</html>
</iframe>
</div>
Now, I want to get everything inside iframe's body as an String. I tested $("#editor").contents().find("body")
, but this return me an object, not string. Also tried $("#editor").contents().find("body").outerHTML
, but this return me undefined
. How can I do this? Please help me. Thank you for your time.
Edit:
I use SCEditor plugin. As Ramesh said, I used val()
method, but still return me (an empty string)
in the firebug console. Here is my code:
var instance = $("textarea").sceditor({
plugins: "bbcode",
style: "../../editor/minified/jquery.sceditor.default.min.css",
//some othe options
});
$("#save").click(function(){
console.log(instance.val());
});
As Ramesh suggests, I used $('textarea').sceditor('instance').val()
and it worked.
In SCEditor to fetch the value of the rich text box, you have to use the .val
method
val() Since: 1.3.5
Gets the current value of the editor.
This will return the filtered HTML from the WYSIWYG editor or the unfiltered contents of the source editor.
If using a plugin that filters the HTML like the BBCode plugin, this will return the filtered HTML or BBCode in the case of the BBCode plugin.
Syntax
var val = instance.val();
Return Type:
String
The filtered value of the editor