Skip to content

Commit

Permalink
Add onFocus example to example.html.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemorton committed Sep 23, 2011
1 parent 82022f5 commit 20803a7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion example.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ <h2>&lt;textarea&gt; Example</h2>
after: <input type="checkbox" id="textarea-string-after" />
<button id="textarea-ex-string">Jump to string</button>
</div>

<h2>onFocus Example</h2>
<p>
<input type="text" id="onfocus-ex" value="Hello world!" />
</p>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script src="jquery.caret.js"></script>
<script>
jQuery(function ($) {
var $inputExample = $('#input-ex'),
$textareaExample = $('#textarea-ex');
$textareaExample = $('#textarea-ex'),
$onFocusExample = $('#onfocus-ex');

$('#input-start').click(function () {
$inputExample.caretToStart();
Expand Down Expand Up @@ -93,6 +99,12 @@ <h2>&lt;textarea&gt; Example</h2>
$('#textarea-buttons').click(function () {
if (console.log) console.log($textareaExample.caret());
});

$onFocusExample.focus(function () {
// Delay needed to escape focus since
// native focus cannot be suppressed
$(this).delay(13).caretToEnd();
});
});
</script>
</body>
Expand Down

0 comments on commit 20803a7

Please sign in to comment.