0
我有一個HTML標記這樣如何使用點擊事件jQuery的
<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,當我點擊任何處理模糊事件時。現在我的要求是在輸入框內有一個十字圖標,當我點擊十字圖標時,我必須執行一些任務,但是我不想點擊十字圖標時點燃模糊。如果已經有模糊事件,請告訴我如何處理點擊。
哪一個是對標記的十字圖標? – rgin 2012-04-17 07:51:00
這是我用於交叉圖標和$ stopSearch.click(函數(事件){})的標記,這裏是事件。 – Soarabh 2012-04-17 07:52:25
你還可以添加正確的樣式的小提琴嗎?它將有助於加速尋找解決方案。 – rgin 2012-04-17 07:55:45