首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

div 内部的select 的下拉选项 失焦解决思路

2013-11-09 
div 内部的select 的下拉选项 失焦html:div classall-goodsdiv classitemdiv classproduct

div 内部的select 的下拉选项 失焦
  


html:
<div class="all-goods">
        <div class="item">
          <div class="product">
            <h3> <a href="#">服务机构</a> </h3>
            <s></s> 
           </div>
          <div class="product-wrap posone" style="height:360px;"> 
            <div class="cf">
              <div class="fl wd460 pl20 blee">
                <p style="color:#e86842;font-size:17px;">xxx</p>
                <br/>
                
                <p style="height:38px;"><select>
<option>请选择验证方式</option>
<option>请选择验证方式</option>
<option>请选择验证方式</option></select>&nbsp;&nbsp;</p>
                
            </div>
            </div>
          </div>

js:
$(function(){

$('.all-goods .item').hover(function(){
$(this).addClass('active').find('s').hide();
$(this).find('.product-wrap').show();
},function(){
$(this).removeClass('active').find('s').show();
$(this).find('.product-wrap').hide();
});
});



为什么选着下拉选项的时候,hover就会失焦啊,有人能指教下么 JS hover
[解决办法]
IE下移动到option下会有这个问题,你判断下判断下是否在select上

    var selFocus = false;
    $(function () {
        $('.all-goods .item').mousemove(function (e) { selFocus = e.target.tagName;document.title=selFocus+"
[解决办法]
"+new Date().getTime });
        $('.all-goods .item').hover(function () {
            $(this).addClass('active').find('s').hide();
            $(this).find('.product-wrap').show();
        }, function () {
            if (selFocus) return;
            $(this).removeClass('active').find('s').show();
            $(this).find('.product-wrap').hide();
        });
    });
[解决办法]
引用:
IE下移动到option下会有这个问题,你判断下判断下是否在select上

    var selFocus = false;
    $(function () {
        $('.all-goods .item').mousemove(function (e) { selFocus = e.target.tagName;document.title=selFocus+"
[解决办法]
"+new Date().getTime });
        $('.all-goods .item').hover(function () {
            $(this).addClass('active').find('s').hide();
            $(this).find('.product-wrap').show();
        }, function () {
            if (selFocus) return;
            $(this).removeClass('active').find('s').show();
            $(this).find('.product-wrap').hide();
        });


    });


同意

热点排行