您好,登录后才能下订单哦!
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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。