I have aa html with many textarea elements.
I need select all them, take your id to use in a JQuery function and set a text editor.
Here is what I did, but I have no success with my JS.
HTML:
<textarea id="editor1" name="namedit1"
data-editor="ck">
</textarea>
<textarea id="editor2" name="namedit2"
data-editor="ck">
</textarea>
....
<textarea id="editorN" name="nameditN"
data-editor="ck">
</textarea>
JS:
$("textarea").find(['data-editor="ck"']).each(
function(){
var input = $(this);
CKEDITOR.replace( input.id), {
uiColor: '#9AB8F3'
};
});
You are trying to find a text area element inside the text area.
Try with:
$('textarea[data-editor="ck"]').each(function(){
CKEDITOR.replace($(this).attr('id')), {
uiColor: '#9AB8F3'
};
});
Change your selector to $("textarea[data-editor=ck]")
and make sure it's called on the page ready event.
Working demo: https://jsfiddle.net/52wb240h/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.