如果您想擴展一個包含超過20個字符的input type=text
,我有一個完美的函數。我的問題是,如何將此功能用於禁用的輸入?爲了更好地理解我的函數的行爲,檢查撥弄我的例子: http://jsfiddle.net/DCjYA/168/禁用元素的調用函數
$('input[type!="submit"]').focus(function(){
if ($(this).val().length > 20) {
$(this).attr('data-default', $(this).width());
$(this).animate({width: 300}, 'slow');
$(this).parent().addClass('cooling');
}
}).blur(function(){
var w = $(this).attr('data-default');
$(this).animate({
width: w
}, 'slow');
$(this).parent().removeClass('cooling');
});
謝謝。
在IE :( – mcmwhfy
不工作,嘗試$(「輸入[禁用]')..它會在所有 –
工作不,它不工作在IE8上:((檢查小提琴 – mcmwhfy