[英]How to handle blur event with click event jquery
我有这样的html标记
<li id="fSearch" class="alwsShown">
<div class="dark overflowHidden" id="fSearchBg">
<input type="text" id="filter" name="" style="width:140px" tabindex="1" class="fullWidth opt resetBorderNShd resetShd" value="" autocomplete="off" title="Search" value=""/>
<span id="stopSearch" class="imgSprite stopSearch displayNone poAbs"></span>
</div>
</li>
二手jQuery
var test = function() {
var self = this,
$filter = $("#filter"),
$fSearchBg = $("#fSearchBg"),
$stopSearch = $(".stopSearch");
// Blur
$filter.blur(function() {
$filteranimate({
width: "140px"
}, 200, function() {
$fSearchBg.removeClass("light").addClass("dark");
$stopSearch.hide();
});
});
$stopSearch.click(function(event){
$filter.val("");
$(this).hide('fast');
event.preventDefault()
event.stopPropagation();
});
// Focus
$filter.focus(function() {
// animate
$filter.animate({
width: "285px"
}, 200);
$fSearchBg.removeClass("dark").addClass("light");
});
});
在我的情况下,我的输入框的宽度为140px,当用户专注于输入框时,我会将其设置为284px的动画,而当我单击任何地方时,我将处理模糊事件。 现在我的要求是,当我单击十字图标时,输入框内有一个十字图标,我必须执行一些任务,但我不想在单击十字图标时产生模糊。 如果已有模糊事件,请建议我如何处理点击。
如果您可以检测到该图标,请点击设置一些全局javascript标志,例如
iconclicked = true;
使用此iconclick中的模糊方法,如果为true,则返回
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.