读书人

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

发布时间: 2013-11-09 17:06:47 作者: rapoo

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>  </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();
});


});


同意

读书人网 >JavaScript

热点推荐