2017-12-02 60 views
0

您好有人可以幫助我如何我可以改變焦點從搜索圖標X圖標,這是我的代碼:焦點改變輸入搜索發發圖標

<form class="navbar-form navbar-left" role="search" style="padding-top: 42px;padding-left: 75px;"> 
    <div class="input-group"> 
     <div class="form-group"> 
      <input style=" background: #f2f2f2;" type="text" class="form-control search" placeholder="search" name="search" id="navbar-search-input"> 
     </div> 
     <div class="input-group-btn"> 
      <button type="button" id="btnSearch" style=" " class="btn btn-success btnSearch"><i class="fa fa-search"></i></button> 
     </div> 
    </div> 
</form> 

回答

0

的訣竅是使用+到選擇下一個兄弟,請檢查例子

.navbar-form input:focus + .input-group-btn > .btn > i:before{ 
 
    content: "\f00d"; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> 
 
<form class="navbar-form navbar-left" role="search" style="padding-top: 42px;padding-left: 75px;"> 
 
    <div class="input-group"> 
 
     <input style=" background: #f2f2f2;" type="text" class="form-control search" placeholder="search" name="search" id="navbar-search-input"> 
 
    <div class="input-group-btn"> 
 
     <button type="button" id="btnSearch" style=" " class="btn btn-success btnSearch"> 
 
     <i class="fa fa-search"> 
 
     </i> 
 
     </button> 
 
    </div> 
 
    </div> 
 
</form>