2012-04-17 115 views
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,当我点击任何处理模糊事件时。现在我的要求是在输入框内有一个十字图标,当我点击十字图标时,我必须执行一些任务,但是我不想点击十字图标时点燃模糊。如果已经有模糊事件,请告诉我如何处理点击。

+0

哪一个是对标记的十字图标? – rgin 2012-04-17 07:51:00

+0

这是我用于交叉图标和$ stopSearch.click(函数(事件){})的标记,这里是事件。 – Soarabh 2012-04-17 07:52:25

+0

你还可以添加正确的样式的小提琴吗?它将有助于加速寻找解决方案。 – rgin 2012-04-17 07:55:45

回答

1

如果可以检测到点击图标设置一些全局JavaScript标志像

iconclicked = true; 

使用此iconclicked中的模糊方法并返回如果这是真的