|
|
Here’s how to animate and expand the height and width of a TextBox when it receives focus. After a delay, the TextBox returns to its normal size
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Expand a TextBox on Focus in jQuery</title>
<style type="text/css">
.txt
{
width:100px;
height:15px;
}
</style>
<script type="text/javascript"
src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js">
</script>
<script type="text/javascript">
$(function () {
$(".txt").focus(function () {
$(this).animate({
width: '200px',
height: '40px'
},
"slow"
)
.delay(2000)
.animate({
width: '100px',
height: '15px'
},
"slow"
);
});
});
</script>
</head>
<body>
<div>
<input class="txt" type="text"
value="Some Text Some Text Some Text" /><br />
</div>
</body>
</html>
The code is self explanatory. We first animate the height and width of the TextBox and increase its size. We then set a delay() and then animate the height and width back to what it was earlier.
See a Live Demo
'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
0 Responses to "Expand a TextBox on Focus using jQuery"Post a Comment