Javascript 当滚动一个“";“可滚动”;div

Javascript 当滚动一个“";“可滚动”;div,javascript,jquery,scroll,ckeditor,Javascript,Jquery,Scroll,Ckeditor,我有一个“可滚动的”div。在这个div中,我有一些文本和另一个contenteditable=true的div HTML源代码如下所示 <div id='scrollable' style="overflow:scroll;height:500px;width:90%;position:absolute"> some text <div id='editable' style="color:red" contenteditable=true>editable di

我有一个“可滚动的”div。在这个div中,我有一些文本和另一个contenteditable=true的div

HTML源代码如下所示

<div id='scrollable' style="overflow:scroll;height:500px;width:90%;position:absolute">
some text
   <div id='editable' style="color:red" contenteditable=true>editable div</div>
some text
</div>
问题是,当我滚动“scrollable”div时,内联编辑器保持在屏幕上。当我滚动时,我希望它保持在“屏幕外”。我的意思是,我希望它像可滚动div中的常规元素一样工作


我准备了一个测试,但我建议查看结果页面。在FF和Chrome中测试,您可以执行以下操作

$( document ).ready(function() {
  // Handler for .ready() called.
  $("#editable").focus();
     setInterval(function(){$("#cke_editable").css("top",($("#editable").offset().top - $("#cke_editable").height())+"px")})
});

查看它的工作情况

谢谢你的回答,但它只在Chrome中工作,在FF中不工作。我为setInterval(10)添加了一个时间参数,现在它在FF中工作。我会做一些测试,如果它对我有效,我会把你的答案设置为被接受。这很好。。。我刚才给你举了个例子。。。如果要使用多个编辑器,则必须进行更多的添加。
$( document ).ready(function() {
  // Handler for .ready() called.
  $("#editable").focus();
     setInterval(function(){$("#cke_editable").css("top",($("#editable").offset().top - $("#cke_editable").height())+"px")})
});