I am trying to execute a function with respect to the clicked element (here div with .redactor
class).
If clicked the specified element (.redactor
), then execute this function:
$('.redactor').on("click", function() {
$(".redactor").each(function () {
if($(this).hasClass("selected"))
{
destroy_redactor(current_edit);
$(this).removeClass("selected");
}
});
$(this).addClass("selected");
current_edit = $(this);
initialize_redactor(current_edit);
});
Or if clicked other than the specified element, execute this function if there is already an initialized redactor or else do nothing:
destroy_redactor(current_edit);
I saw this post as a reference. But it is not helping. It just removes all the divs.
I can't figure out how to execute the destroy_redactor(current_edit)
function when clicked outside the .redactor
div while there is already an initialized redactor for the current_edit
.
Sample in codepen.io