1
好吧,所以我得到了元素編碼等。它有點奇怪,因爲如果表單是空的,一個清晰的按鈕會以圖像形式顯示:(x)顯示一個元素,如果文本輸入不是空的使用jQuery
這是腳本,頁面加載時jQuery重點關注文本輸入字段,同時顯示(x)清除類。我希望達到的是這個。
在頁面加載時,jQuery仍然關注文本輸入字段,但它不顯示清晰的類(x),但只有在輸入文本字段中至少有1個字符時纔會顯示它,其他vise不顯示。
這裏是當前的代碼
$(document).ready(function() {
$('#ui_query').focus();
});
$('#ui_query').focus(function() {
$('.clear-helper').css('opacity','0.9999');
});
$(document).focusout(function() {
$('.clear-helper').css('opacity','0.3333');
});
(function ($, undefined) {
$.fn.clearable = function() {
var $this = this;
$this.wrap('<div class="clear-holder" />');
var helper = $('<span class="clear-helper"></span>');
$this.parent().append(helper);
helper.click(function(){
$this.val("");
$('#ui_query').focus();
});
};
})(jQuery);
$("#ui_query").clearable();