Roman Nrokov Roman Nrokov - 1 year ago 97
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() {

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download