Is it possible to assign a function to clear an input field if you hold the mouse down on it? Currently i've got the following http://jsfiddle.net/e1kb6esm/6/ where if you click on a field, it increases by one, but what I also need to do is to be able to clear the field if it was clicked by mistake. I was thinking of something to do with
if $this.mousedown(function(e) {
but if I cleared on mousedown it'd also clear the increasing values on click too?
Code:
<input class="played" type="text" value="" /><br>
<input class="played" type="text" value="" /><br>
<input class="played" type="text" value="" /><br>
<input class="played" type="text" value="" /><br>
<input class="played" type="text" value="" />
$('.played').on('focus', function () {
var $this = $(this);
if ($this.val() == '') {
$this.val('1');
$this.blur();
} else {
var value = parseInt($this.val());
$this.val(value + 1);
$this.val();
$this.blur();
}
});