小编Soh*_*tel的帖子

jquery 输入字段焦点移出,div 除外

我正在提出 ajax 搜索建议,其中将显示一个建议框

<div id="searchbox">
    <input type="text" name="search" class="searchinput"/>
</div>

<div id="sugbox">
 ......
 <a href="product.php?id=2" >Item 1</a>
 .....
</div>
Run Code Online (Sandbox Code Playgroud)

JavaScript

$('#searchbox .searchinput').focus(
 function () {
    $('#searchbox #sugbox').show();
 });

 $('#searchbox .searchinput').focusout(
 function () {
    $('#searchbox #sugbox').hide();
 });
Run Code Online (Sandbox Code Playgroud)

如果搜索文本框#searchbox .searchinput为则建议框将打开focus,如果为 则隐藏focusout。问题:每当我单击建议框上的链接时,建议框就会隐藏(由于输入焦点事件)。

我如何检查目标 div 是否是建议框,所以不要隐藏该框 ex ..

 $('#searchbox .searchinput').focusout(
 function () {
    if(target div is not sugbox)
        $('#searchbox #sugbox').hide();
 });
Run Code Online (Sandbox Code Playgroud)

html javascript css ajax jquery

3
推荐指数
1
解决办法
2113
查看次数

使用z-index重叠带有图像的div

CSS动画在图像后面不断播放.未加载图像时,它将显示,但加载后图像将与动画重叠.我正在使用z-index来实现这一点,但它无法正常工作.

图像应隐藏使用z-index属性加载动画.

注意:我无法使用任何javascript解决方案来隐藏加载动画并在图像加载后显示它.

CSS/HTML/Demo

.leftprev {
    overflow:auto;
    position:absolute;
    height:99%;
    width:85%;
}
.loadingslide {
    z-index: 50; /* Loading div's z-index */    
}
.spinner.big {
    display: block;
    height: 40px;
}
.spinner {
    bottom: 0;
    display: none;
    font-size: 10px;
    height: 30px;
    left: 0;
    margin: auto;
    position: absolute;
    right: 0;
    text-align: center;
    top: 0;
    width: 60px;
}
.spinner.big > div {
    width: 6px;
}
.spinner > div {
    animation: 1.2s ease-in-out 0s normal none infinite stretchdelay;
    background-color: #333;
    display: inline-block;
    height: 100%;
    width: …
Run Code Online (Sandbox Code Playgroud)

html css css3

2
推荐指数
1
解决办法
8080
查看次数

标签 统计

css ×2

html ×2

ajax ×1

css3 ×1

javascript ×1

jquery ×1