get the id of a textarea from this html form with jQuery

Need help getting and using the id of a textarea so that I can replace it with a ckEDITOR.

So here is the html output:

NOTE: This is the output of a foreach loop, for every database result, this is the html output and the textarea ID is a number generated from the id of the row.

<div class="blogtest" id="514">
<form action="process/updatepost.php" class="updatepost" method="post">
<input type="button" class=edity value="Edit">
// SOME BUTTONS
<br>
<div class="text">
<div class="buildtext" id="514">3</div>
<div class="editor">
<textarea name="muffin" id="516" class="ckeditor">3</textarea>
</div>
</div>
</form>
</div>

And here is the jQuery im using:

$(document).on('click','.edity',function(){
var editorID = $(this).find('.ckeditor').attr("id")
CKEDITOR.replace(editorID);
});

This doesnt work, I'm not the most advanced with jQuery so not sure why. But i get a type b is undefined error in my console log.

Also just to note; this works:

CKEDITOR.replace('516');

but the text areas are loaded dynamically in a foreach loop and I can't be creating a replace code for 1000's of editors...

Answers


You are looking for the .checkeditor element from the .edity element. Instead you can do:

$(document).on('click','.edity',function() {
    var editorID = $(this).parents('.blogtest').find('.ckeditor').attr("id");
    CKEDITOR.replace(editorID);
});

Need Your Help

How to make the main thread wait for the other threads to complete in ThreadPoolExecutor

java multithreading threadpool

I am using the ThreadPoolExecutor to implement threading in my Java Application.

Function Reference/shortcode exists in wordpress

php wordpress wordpress-plugin

how can i understand a short code is exist in my wordpress post?