gpt4 book ai didi

javascript - tinyMCE 在外面点击,textarea 隐藏

转载 作者:行者123 更新时间:2023-11-29 15:45:33 24 4
gpt4 key购买 nike

我有一个 tinyMCE textarea,在名为 text_editor 的 div 中。所以我在我的 jQuery 中有:

$('#text_editor').hover(function(){ 
mouse_is_inside=true;
}, function(){
mouse_is_inside=false;
});

$('body').mouseup(function(){
if(! mouse_is_inside){
$('#text_editor').hide();

}
});

当用户在 div 文本编辑器外部单击时,这将隐藏,但如果用户选择字体系列或字体大小,文本编辑器将隐藏,所以我将其添加到我的 jQuery 中:

$(document).on('click', '.mceMenuItem, .mceColorSplitMenu, .mceBottom, .mceMoreColors', function(e){
e.stopPropagation();
$('#text_editor').show();
});

这解决了开销问题。但如果用户点击颜色选择器 - 更多颜色,一个新窗口打开,text_editor 隐藏,我不希望这样。

最佳答案

demo

var $editor = $('#text_editor');

$('textarea').click(function(e){
e.stopPropagation();
$editor.fadeTo(400,1);
});


$('body').on('click', function ( e ) {
if( !($(e.target).is('#text_editor')) && $editor.is(':visible') ){
$editor.hide();
}
});

关于javascript - tinyMCE 在外面点击,textarea 隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12070763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com