jQuery addClass example
Change class name on click in jQuery
HTML
<input type="password" class="db" value="один" />
<a href="#" class="toggle-input db">Показать текст</a>
<br>
<input type="password" class="db" value="два" />
<a href="#" class="toggle-input db">Показать текст</a>
<br>
<input type="password" class="db" value="три" />
<a href="#" class="toggle-input db">Показать текст</a>
CSS
.db {
display: block
}
JavaScript
$('.toggle-input').click(function(){
var $a = $(this),
$input = $a.prev('input').eq(0),
type = $input.attr('type') == "text" ? "password" : 'text',
c = $a.text() === "Скрыть текст" ? "Показать текст" : "Скрыть текст";
$a.text(c);
$input.prop('type', type);
});