如何获得插入符号(文本编辑闪烁光标)的元素的xpath或元素引用,可以通过鼠标单击或使用键盘操作来放置插入符号。
<div class="PPTOutlineViewContent" contentEditable="true" draggable="false">
<div class="PPTOutlineSlide_1 Slide">
<div class="PPTOutlineSlideNumber" contentEditable="false">1</div>
<div class="PPTOutlineSlideTitleSpan line1">Seattle</div>
<div class="PPTOutLineSubtitle line2">With Kodiak West Travel</div>
</div>
<div class="PPTOutlineSlide_2 Slide">
<div class="PPTOutlineSlideNumber" contentEditable="false">2</div>
<div class="PPTOutlineSlideTitleSpan line1"> </div>
</div>
<div class="PPTOutlineSlide_3 Slide">
<div class="PPTOutlineSlideNumber" contentEditable="false">3</div>
<div class="PPTOutlineSlideTitleSpan line1"> </div>
</div>
<div class="PPTOutlineSlide_4 Slide">
<div class="PPTOutlineSlideNumber" contentEditable="false">4</div>
<div class="PPTOutlineSlideTitleSpan line1"> </div>
</div>
<div class="PPTOutlineSlide_5 Slide">
<div class="PPTOutlineSlideNumber" contentEditable="false">5</div>
假设这条线上有插入符号
<div class="PPTOutlineSlideTitleSpan line1">Visit Seattle</div>
<div class="PPTOutlineSlideTitleDiv line2">Before or After</div>
<div class="PPTOutlineSlideTitleDiv line3">Your Cruise to Alaska!</div>
<div class="PPTOutLineSubtitle line4">Kodiak West Travel Can Help </div>
<div class="PPTOutLineSubtitle line5">You Develop Your Itinerary</div>
</div>
</div>
例如:如果在幻灯片5第2行的“访问西雅图”之前存在插入符号,我应该得到该div元素的xpath或元素引用。
答案 0 :(得分:0)
当时文档可以有一个activeElement
。如果页面上有一个闪烁的插入符号,activeElement
指的是该特定元素。可以像这样检索jQuery对象:$(document.activeElement)
或$( ":focus" )
。