The last utility function that we will look at is the Drupal.getSelection() function. This tool is used to find out what portion of a text area (<textarea></textarea>) is selected.
For example, when you select a section of text with your mouse, this function can be used to find out the starting and ending locations of the selection.
The Drupal.getSelection() function returns an object with two attributes: start and end. These two properties are integers which represent the beginning and ending of the selection. In our next project, we will see this function in action.
There are a few other functions in the drupal.js file that may be used in rare circumstances, but the ones we have seen here are the ones you are most likely to use in your own scripts. In the last part of this chapter, we will do another project. We will create a simple editor with jQuery and some of the Drupal capabilities we have seen in this chapter.
Was this article helpful?