Skip to content

Node plugin to manipulate the caret of inputs and textareas.

License

Notifications You must be signed in to change notification settings

krhkt/yui-caret-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YUI Caret Plugin interface for Node

Node plugin to manipulate the caret of inputs and textareas. Try it out.

Note:This plugin only works with input or textarea nodes. (node.caret)

Methods:

isValidNode():
checks if this node is a textarea or a valid type input.
insert(content):
insert the content at the current caret position in the textarea/input as if the user itself had typed.
clearSelection():
deselect the actual selection and place the caret at the begining.
selectAll():
select all the content inside the textarea/input.

Attributes:

selectionStart:
gets or sets the start of a selection in the node.
selectionEnd:
gets or sets the end of a selection in the node.
range:
gets an object like {start: #, end: #}, where the # is the index number of the start and end indexes of the selection.
(in case the caret isn't selecting anything, the start and end will be the same)
sets the selection passing an object like{start: #, end: #}.
position:
gets or sets the position of the caret. If the node has a selection, getting the position will return the begining of the selection.
content:
gets selected content.
setting content will insert the new content replacing the selected content and keeping the selection.

About

Node plugin to manipulate the caret of inputs and textareas.

Resources

License

Stars

Watchers

Forks