Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added readme. Moved JS to end of body
- Loading branch information
Showing
3 changed files
with
44 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# autofocusBackspace jQuery plugin | ||
|
||
jQuery plugin that focuses the first of the matching elements while | ||
preserving the backspace functionality of navigating to the previous page. | ||
|
||
Plugin mimics browser backspace behaviour until: | ||
* Actual text has been entered | ||
* The element that received autofocus loses it's focus | ||
|
||
## Usage | ||
* Include jQuery | ||
* Include jQuery.autofocusBackspace.js | ||
* Call plugin, example: | ||
|
||
$('input').autofocusBackspace(); | ||
|
||
## TODO: | ||
* If disabled, remove event handlers to prevent unneccessary code execution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>jQuery autofocusBackspace plugin</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> | ||
<script src="js/jquery.autofocusBackspace.js"></script> | ||
<script> | ||
jQuery(document).ready(function($) { | ||
$('input').autofocusBackspace(); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<form> | ||
<p>Pressing backspace will return to the previous page only if:</p> | ||
<ul> | ||
<li>Not having already typed anything in the input field. | ||
<li>Not in the meantime having lost focus. | ||
</ul> | ||
<dl> | ||
<dt><label for="myInput1">This field will get focus:</label></dt> | ||
<dd><input type="text" id="myInput1"></dd> | ||
<dt><label for="myInput2">And this field will not:</label></dt> | ||
<dd><input type="text" id="myInput2"></dd> | ||
</dl> | ||
</form> | ||
</body> | ||
<head> | ||
<title>jQuery autofocusBackspace plugin</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
</head> | ||
<body> | ||
<form> | ||
<p>Pressing backspace will return to the previous page only if:</p> | ||
<ul> | ||
<li>Not having already typed anything in the input field. | ||
<li>Not in the meantime having lost focus. | ||
</ul> | ||
<dl> | ||
<dt><label for="myInput1">This field will get focus:</label></dt> | ||
<dd><input type="text" id="myInput1"></dd> | ||
<dt><label for="myInput2">And this field will not:</label></dt> | ||
<dd><input type="text" id="myInput2"></dd> | ||
</dl> | ||
</form> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> | ||
<script src="js/jQuery.autofocusBackspace.js"></script> | ||
<script> | ||
$('input').autofocusBackspace(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters