I am new to ckeditor, at moment I am writting a demo code on ckeditor. Could someone please help me how to get value from texterea ckeditor. Here below is my code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor 4</title>
</head>
<body>
<textarea id="idDemo" name="demo"></textarea>
<input type="button" value="Get Data" onclick="myFunction()" />
<script>
function myFunction() {
var content = $('idDemo').val();
alert(content);
}
</script>
<script src="ckeditor/ckeditor.js"></script>
<script>CKEDITOR.replace('demo');</script>
</body>
</html>
According to the documentation, this should do the trick.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor 4</title>
</head>
<body>
<textarea id="idDemo" name="demo"></textarea>
<input type="button" value="Get Data" onclick="myFunction()" />
<script>
function myFunction() {
var content= CKEDITOR.instances.editor1.getData();
alert(content);
}
</script>
<script src="ckeditor/ckeditor.js"></script>
<script>CKEDITOR.replace('demo');</script>
</body>
</html>