2016-08-12 2 views
0

Ich benutze Fundament-Schienen, um ein Anmeldeformular zu erstellen. Innerhalb eines div:Symbol in text_field_tag ​​(Fundament-Schienen)

<%= text_field_tag "password", "", placeholder: password", class:"password", required: true, type: "password" %> 
<small class="error">Invalid</small> 

ich ein „Show-Passwort“ oder ein Symbol in diesem Feld haben will (auf der rechten Seite), auf klicken, von denen das Passwort angezeigt werden soll.

Wie man eine font awesome icon in einem text_field_tag ​​???

Antwort

1
<div class="password"> 
    <span class="fa fa-eye"></span> 
    <%= text_field_tag "password", "", placeholder: password", class:"password", required: true, type: "password" %> 
</div> 

zu css hinzufügen für Ihre Antwort

.password { 
    position: relative; 
} 

.password input { text-indent: 32px;} 

.password .fa-eye { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    cursor: pointer; 
} 

Add js Skript

<script> 
    $('.password').find('.fa-eye').click(function(){ 
     $('#password').prop("type", "text"); 
    }) 
</script> 
+0

Dank. Es hat super funktioniert. außer für $ ('# password'). type = 'text'; '. Stattdessen habe ich '$ (" # password ") verwendet. Prop (" type "," text ");' – smanvi12

+0

Vielen Dank für Ihre Nachricht. Ich habe die Antwort bearbeitet –

Verwandte Themen