Reputation: 2645
I have a a 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'
};
});
Upvotes: 1
Views: 2771
Reputation: 10649
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/
Upvotes: 0
Reputation: 2223
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'
};
});
Upvotes: 1