Created
October 12, 2012 09:37
-
-
Save digitup/3878397 to your computer and use it in GitHub Desktop.
jQuery: Extend search box width
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
<html><body> | |
<style> | |
#search { | |
background-color: #999; | |
width: 100px; | |
border: 1px solid #ddd; | |
outline: none; | |
} | |
</style> | |
<input id="search" /> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script> | |
<script> | |
jQuery(function() { | |
jQuery('#search').focus(function() { | |
jQuery(this).animate({ width: '200px', backgroundColor: '#fff' }); | |
}).blur(function() { | |
jQuery(this).animate({ width: '100px', backgroundColor: '#999' }); | |
}); | |
}); | |
</script> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment