4
我正在使用此javascript在集中時清空輸入/文本區域。從jQuery選擇器中排除具有特定屬性的元素
$(document).ready(function() {
$('input[type="text"],textarea').not('[readonly="readonly"]').addClass("idleField");
$('input[type="text"],textarea').focus(function() {
$(this).removeClass("idleField").addClass("focusField");
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
});
$('input[type="text"],textarea').blur(function() {
$(this).removeClass("focusField").addClass("idleField");
if ($.trim(this.value) == ''){
this.value = (this.defaultValue ? this.defaultValue : '');
}
});
});
我正在尋找一種方法來排除那些input
字段,通過readonly="readonly"
設置readonly
。我知道我應該使用.not
(我猜),但我不知道如何。