I am trying to fetch content that has been typed in the editor div of quill editor http://quilljs.com/examples/ using jquery codes but it does not seem to work. It works for other text inputs but not for the editor div. I have a running illustration below .
$(function(){
$(document).on("click", "#SubmitButton", function(e) {
e.preventDefault();
{
var question = $("#question").val();
var title = $("#title").val();
alert (question);
alert (title);
e.preventDefault();
}
});
});
advancedEditor = new Quill('#question', {
modules: {
'toolbar':
{
container: '#toolbar'
},
'link-tooltip': true,
'image-tooltip': true,
'multi-cursor': true
},
styles: false,
theme: 'snow'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.quilljs.com/0.20.1/quill.js"></script>
<link href="http://cdn.quilljs.com/0.20.1/quill.snow.css" rel="stylesheet"/>
<form id="postform" name="postform" action="">
Title
<input type="text" name="title" id="title">
<br>
<div class="advanced-wrapper" id="qs" style="width:95%; padding:0px; margin:0px;">
<div class="toolbar-container" id="toolbar"><span class="ql-format-group">
<select title="Font" class="ql-font">
<option value="sans-serif" selected>Sans Serif</option>
<option value="Georgia, serif">Serif</option>
<option value="Monaco, 'Courier New', monospace">Monospace</option>
</select>
<select title="Size" class="ql-size">
<option value="10px">Small</option>
<option value="13px" selected>Normal</option>
<option value="18px">Large</option>
<option value="32px">Huge</option>
</select></span><span class="ql-format-group"><span title="Bold" class="ql-format-button ql-bold"></span><span class="ql-format-separator"></span><span title="Italic" class="ql-format-button ql-italic"></span><span class="ql-format-separator"></span><span title="Underline" class="ql-format-button ql-underline"></span></span><span class="ql-format-group">
<select title="Text Color" class="ql-color">
<option value="rgb(187, 187, 187)"></option>
<option value="rgb(161, 0, 0)"></option>
</select><span class="ql-format-separator"></span>
<select title="Background Color" class="ql-background">
<option value="rgb(0, 0, 0)"></option>
<option value="rgb(230, 0, 0)"></option>
</select><span class="ql-format-separator"></span>
<select title="Text Alignment" class="ql-align">
<option value="left" selected></option>
<option value="center"></option>
<option value="right"></option>
<option value="justify"></option>
</select></span><span class="ql-format-group"><span title="Link" class="ql-format-button ql-link"></span><span class="ql-format-separator"></span><span title="Image" class="ql-format-button ql-image"></span><span class="ql-format-separator"></span><span title="List" class="ql-format-button ql-list"></span></span></div>
<div id="question" class="editor-container"></div>
</div>
<input type="submit" class="btn btn-info" id="SubmitButton" value="Post Your Question" />
</form>
I want when i click the submit button, It captures also the content typed in the text editor div and alerts the values types.
Any help will be appreciated