插件来处理选择? [英] Plugin to handle selection?

查看:87
本文介绍了插件来处理选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能建议一个可以处理文本区域(跨浏览器)中的文本选择的插件?

我正在寻找可以执行以下操作的插件

:
  • 获取当前选择
  • 替换当前选择
  • 选择一个范围

(IE使用createTextRange,而其他浏览器使用setSelectionRange.应该存在一个可以完成上述操作的插件,这样我就不必重新发明轮子了.)

解决方案

jQuery字段选择: https://github.com/localhost/jquery-fieldselection

请参阅: https://github.com/localhost/jquery-fieldselection/blob/master/jquery-fieldselection.js

实现: getSelection,replaceSelection

未实现: currentSelection

范围: 实现: getSelection,ReplaceSelection,CurrentSelection

(注意:这不是jquery插件,但仍可广泛使用)

跨浏览器的JavaScript范围和选择库.它提供了一个简单的基于标准的API,可在所有主要浏览器中执行常见的DOM范围和选择任务,从而抽象出Internet Explorer与DOM兼容的浏览器之间此功能的千差万别的实现.

似乎可以实现您想要的功能,有关演示的信息,请参见: http://rangy.googlecode.com/svn/trunk/demos/core. html

http://code.google.com/p/rangy/

另请参阅: Jquery:非文本区域元素的selectionStart

范围输入 一个jQuery插件,提供与Rangy类似的功能,除了输入而不是套利DOM元素.

一个小的跨浏览器JavaScript库,用于获取和处理HTML元素中的选择.

演示: http://rangyinputs.googlecode.com/svn/trunk /demos/textinputs_jquery.html

项目: http://code.google.com/p/rangyinputs/

Can anyone suggest a plugin which can handle text selections in text areas (cross browser)?

I'm looking for a plugin which can:

  • Get current selection
  • Replace current selection
  • Select a range

(IE uses createTextRange while other browsers use setSelectionRange. There ought to exist an plugin which can do the above so that I don't have to reinvent the wheel.)

解决方案

jQuery Fieldselection: https://github.com/localhost/jquery-fieldselection

See: https://github.com/localhost/jquery-fieldselection/blob/master/jquery-fieldselection.js

Implements: getSelection, replaceSelection

Does not implement: currentSelection

Rangy: Implements: getSelection, ReplaceSelection, CurrentSelection

(note: not a jquery plugin, but widely applicable still)

A cross-browser JavaScript range and selection library. It provides a simple standards-based API for performing common DOM Range and Selection tasks in all major browsers, abstracting away the wildly different implementations of this functionality between Internet Explorer and DOM-compliant browsers.

Seems to implement what you want, for demo's see: http://rangy.googlecode.com/svn/trunk/demos/core.html

http://code.google.com/p/rangy/

See also: Jquery: selectionStart for non textarea elements

Rangyinputs A jquery plugin that offers similar functionality as Rangy, except for inputs instead of arbitrairy DOM elements.

A small cross-browser JavaScript library for obtaining and manipulating selections within and HTML elements.

Demo: http://rangyinputs.googlecode.com/svn/trunk/demos/textinputs_jquery.html

Project: http://code.google.com/p/rangyinputs/

这篇关于插件来处理选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆