87,907
社区成员
发帖
与我相关
我的任务
分享
$(id).focus(function () {
$(id).attr({ "rows": "5", "cols": "50" });
});
$(id).blur(function () {
$(id).attr({ "rows": "2", "cols": "20" });
});
<form id="myForm" action="blank.html" method="post">
Name <br /><input type="text" name="name" /><br />
Comment<div style="height:80px;position:relative;"> <textarea rows="2" cols="20" id="commet" style="position:absolute;heigth:50px;"></textarea></div>
<input type="submit" value="Submit Comment" />
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script>
$('#commet').focus(function () {
$(this).attr({ "rows": "5", "cols": "50" });
}).blur(function () {
$(this).attr({ "rows": "2", "cols": "20" });
});
</script>