Handle text input focus lost(blur) event
Description
The following code shows how to handle text input focus lost(blur) event.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.6.4.js'></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css">
<script type='text/javascript'
src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!-- w w w . j a v a2 s . c om-->
$('#search_field').live('focus', function(event) {
if ($(this).val() == 'Search Applications') {
$(this).val('');
}
});
$('#search_field').live('blur', function(event) {
if ($(this).val().length == 0) {
$(this).val('Search Applications');
}
});
});//]]>
</script>
</head>
<body>
<div data-role="page" class="type-home">
<div data-role="content">
<input type="text" id="search_field" value="Search Applications" />
</div>
</div>
</body>
</html>