正如你所看到的,我試圖增加文本字段的高度,當用戶鍵入它並且當他點擊時(元素失去焦點),我正在縮小它。jQuery onfocus和onblur事件縮小
有沒有更簡單的方法來編寫下面的代碼?
簡單的HTML輸入字段:
<input type="text" />
的jQuery:
$(document).ready(function() {
$('input').on('focus', function() {
$(this).height('20px');
});
$('input').on('blur', function() {
$(this).height('12px');
});
});
你可以只用CSS這樣做:'輸入:重點{高度:20px的; }' –
那麼我正在學習jQuery,想知道jQuery的方式沒有CSS方式。 –