Insert text into text area by query
-
04-06-2021 - |
سؤال
I am trying to insert some text into <textarea>
by query but it is not working as I expect. I expect the colour code should get inserted into the textarea
but textarea
remains blank.
HTML code
<p id="niceedit">
<script src="js/create/text_editor/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({height : 100}).panelInstance('area5');
});
</script>
<textarea id="area5" ></textarea>
</p>
Jquery code
$(document).ready(function(){
$('.simple_color').simpleColor();
$('input#alert_button').click( function() {
var currentlySelectedColor = $('input.simple_color')[0].value;
$('#area5').val(currentlySelectedColor);//HERE IS THE CODE
$.post("defualt_templates/T1/Class_File/template_editor.php", { bgcolor: currentlySelectedColor },
function(data) {
refreshIFrame();
});
});
});
Question
What am I doing wrong?
Reference to external library
المحلول
try this
$('#area5').text(currentlySelectedColor);
instead of this
$('#area5').val(currentlySelectedColor);
Or, there is a method inside NicEditor to find editor and then get or set the content.
reference : http://wiki.nicedit.com/w/page/521/Javascript%20API
لا تنتمي إلى StackOverflow