Auto Set Focus On Text Field Or Editable Element - jQuery focusEnd

File Size: 2.42 KB
Views Total: 1439
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Auto Set Focus On Text Field Or Editable Element - jQuery focusEnd

focusEnd is a small jQuery plugin that auto sets focus on the text field or contentEditable element and makes the cursor appear at the end of its content.

How to use it:

1. Download and insert the focusEnd's JavaScript file jquery.focusEnd.js at the end of the document.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.focusEnd.js"></script>

2. Call the function on the target editable element and done. The plugin currently supports input field, textarea and HTML5 contentEditable element.

<input type="text" value="sample text">
<script>
$('input').focusEnd();
</script>

<textarea>
  Sample text
</textarea>
<script>
$('textarea').focusEnd();
</script>

<p contenteditable="true">
  Sample text
</p>
<script>
$('p').focusEnd();
</script>

This awesome jQuery plugin is developed by boylett. For more Advanced Usages, please check the demo page or visit the official website.