I need help adding a key value array for this jQuery code I came across. The code does exactly what I need, except I need multiple inputs unlike the single input it provides.
jQuery("#btn").on('click', function() {
var caretPos = document.getElementById("txt").selectionStart;
var textAreaTxt = jQuery("#txt").val();
var txtToAdd = "stuff";
jQuery("#txt").val(textAreaTxt.substring(0, caretPos) + txtToAdd + textAreaTxt.substring(caretPos) );
});
<textarea id="txt" rows="15" cols="70">There is some text here.</textarea>
<input type="button" id="btn" value="OK" />
See here.
I want to have an array such as:
OK => stuff,
YES => more stuff,
NO => no stuff
I'm not that familiar with jQuery, please help.