JavaScript Reference/Javascript Methods/move

Материал из Web эксперт
Перейти к: навигация, поиск

"move()" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> var range; function function1(elem) {

   range = elem.createTextRange()
   var m = range.move("word", 2)
   range.select() 

} </script> <input id="myT" type="text" value="Some sample text"> <input type="button" value="Move cursor" onclick="function1(myT);"> </body> </html>


     </source>
   
  


"move()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |TextRange | +----------------+--------------------------------------------------------------+

     </source>
   
  


"move()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Compacts the text and moves the insertion point of a text to a new location, and returns the number of units moved.

Syntax:

textRangeName.move(param1, param2) Parameters:

   param1   Required; the type of units to move. 
                      character, 
                      word, 
                      sentence, 
                      textedit.
   param2   Optional; the number of units to move.
   
     
     </source>