您好,登錄后才能下訂單哦!
html5代碼:
<div class="ub-f3 ub-ac search_input uc-a1 sc-bg-active uinput ub ub-f1 bc-border uba">
<input oninput="toggleIcon(this);" type="text" onfocus="toggleIcon(this);" onblur="lost(this);" placeholder="關鍵字:姓名" class="ub-f1">
<span class="ub-img ub clear uhide"></span>
</div>
JS代碼:
function toggleIcon(ele){
var inputVal = ele.value;
var clearEle = ele.nextElementSibling;
if(inputVal == ''){
clearEle.className = 'ub-img ub clear uhide';
} else {
clearEle.className = 'ub-img ub clear';
}
}
// 輸入框失去焦點事件
function lost(ele){
var inputVal = ele.value;
var clearEle = ele.nextElementSibling;
setTimeout( function(){ clearEle.className = 'ub-img ub clear uhide'; }, 200);
}
function clearInput(ele){
var inputEle = ele.previousElementSibling;
inputEle.value = '';
ele.className = 'ub-img ub clear uhide';
inputEle.focus();
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。