I'm trying to add multiple strings to an input field via multiple buttons. The problem is, is that every time I click a new button it replaces/overrides the previous insert so I cant add strings only replace.
Would also like to remove the string if the same button is re-clicked
Please see code below and fiddle - http://jsfiddle.net/2khzX/
<input type="text" id="text" style="width: 450px;" />
<br />
<button>Hello</button>
<button>Yes</button>
<button>No</button>
<button>Maybe</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"> </script>
<script>
$("button").on('click', function() {
var text = $(this).text();
$("input").val(text + ',');
});
</script>