2015-09-17 36 views
1

在引導程序中的窗體中添加反饋圖標的標題是否有很好的解決方案?在引導程序中添加對反饋量的標題

<form class="form-horizontal" role="form" action="" method="GET"> 
<div class="form-group has-error has-feedback"> 
    <label class="control-label col-sm-3" for="lastname">Last name</label> 
    <div class="col-sm-6"> 
     <input type="text" name="lastname" class="form-control" id="lastname"> 
     <span class="glyphicon glyphicon-remove form-control-feedback"></span> 
    </div> 
</div> 

該代碼將輸入字段內小紅交叉。現在我想添加此跨度的標題(顯示在懸停上)並更改其光標。最簡單的方法是什麼?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> 
 

 
<form class="form-horizontal" role="form" action="" method="GET"> 
 
\t <div class="form-group has-error has-feedback"> 
 
\t \t <label class="control-label col-sm-3" for="lastname">Last name</label> 
 
\t \t <div class="col-sm-6"> 
 
\t \t \t <input type="text" name="lastname" class="form-control" id="lastname"> 
 
\t \t \t <span class="glyphicon glyphicon-remove form-control-feedback"></span> 
 
\t \t </div> 
 
\t </div> 
 
</form>

+0

做一個片斷代碼,使您的問題 – Vijay

+0

您是否使用這個帶有驗證庫(如果這樣的代碼添加)或這是如何輸入始終是更相關? – vanburen

+0

沒有驗證庫。輸入始終保持那樣。 – user1784025

回答

0

更新的解決方案:

因爲jQuery選擇不能標記與自舉類的跨度,我創造了另一個跨度上的「X」圖標上並添加以此爲目標的腳本。似乎按預期完成這項工作。

<form class="form-horizontal" role="form" action="" method="GET"> 
    <div class="form-group has-error has-feedback"> 
     <label class="control-label col-sm-3" for="lastname">Last name</label> 
     <div class="col-sm-6"> 
      <span id="test" style="position: relative;float:right;width:auto;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 
      <input type="text" name="lastname" class="form-control" id="lastname"> 
      <span class="glyphicon glyphicon-remove form-control-feedback"></span>    
     </div> 

    </div> 
</form> 

$("#test").hover(function() 
{ 
    $(this).attr("title","Click To Close"); 
    $(this).css("cursor","wait"); 
}); 

更新小提琴:http://jsfiddle.net/6gmwhtbf/3/

+0

我更新了我的問題。問題在於,引導程序跨度出現在輸入內部。添加標題屬性不起作用。 – user1784025

相關問題