Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created November 10, 2009 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/230882 to your computer and use it in GitHub Desktop.
Save mrchrisadams/230882 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://github.com/danwrong/low-pro-for-jquery/blob/master/src/lowpro.jquery.js?raw=true"></script>
<style type="text/css" media="screen">
.focus{
background-color:yellow;
color:blue;
}
</style>
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function() {
TextFocusStyler = jQuery.klass({
initialize: function(options) {
this.focusClass = options.focusClass;
},
// Caretaker methods to fix formatting on focus on fields
onfocus: function() {
alert('focussed')
this.element.addClass(this.focusClass);
},
onblur: function() {
alert('blurred')
this.element.addClass(this.focusClass);
}
});
// Add styling to textfields on elements when focussed
jQuery('input.text').attach(TextFocusStyler, { focusClass: 'focus' });
})
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>jQuery Low Pro behaviour</title>
<!-- Date: 2009-11-10 -->
</head>
<body>
<form action="foo" method="get" accept-charset="utf-8">
<label for="some_name">A label</label>
<input type="text" class="text" name="some_name" value="some text that should be styled" id="some_name" />
<p><input type="submit" value="Continue &rarr;"></p>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment