Roman Nrokov Roman Nrokov - 5 months ago 42
jQuery Question

Add value to input by click

I have an input field, by click value become * when I lose my focus field become clean. How to add additional * to input by every single click?

$('body').append("<input type='text' />");

$('input').click(function() {

$('input').mouseleave(function() {


You are replacing the value of the input field. You want to append to it. Change $(this).val('*'); to $(this).val($(this).val() + '*'));