Reputation: 2950
I have a html markup like this
<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>
Used 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");
});
});
In my case my input box is having 140px of width, when a user focus on input box I am animating it to 284px and when i click anywhere I am handling a blur event. Now my requirement is there is a cross icon inside input box when i click on cross icon, I have to perform some task but I didn't want to fire blur when i click on cross icon. please suggest me how to handle click if already there is a blur event.
Upvotes: 0
Views: 492
Reputation: 148110
If you can detect the icon click set some global javascript flag like
iconclicked = true;
Use this iconclicked in blur method and return if it is true
Upvotes: 1