tab wrapping
by rkw79
HTML
<form>
<label>the form</label>
<input type='text'/>
<input type='checkbox'/>
<input type='radio'/>
<textarea></textarea>
<select>
<option></option>
</select>
<div>end form</div>
</form>
CSS
input, select, textarea {
clear: both;
display: block;
margin: 5px;
}
textarea {
rows: 2;
}
JavaScript
var all = $('form').find('input, textarea, select');
var f = all.first();
var l = all.last();
f.keydown(function(e){
if (e.which == 9 && e.shiftKey) {
l.focus();
e.preventDefault();
}
});
l.keydown(function(e){
if (e.which == 9 && !e.shiftKey) {
f.focus();
e.preventDefault();
}
});