Smil Miau Smil Miau - 2 months ago 5
CSS Question

Is it possible to make something like this?

I have a text box where someone can write some text to send me. I want to place some buttons on the page with some signs like "!", "XD" and "#". When someone clicks, for example, the "!" button, the "!" should be inserted to the text box. How can I do this?

<textarea data-typeid="18" data-price="15" data-pricetype="fixed" data-index="0" name="ywapo_textarea_18[0]" cols="20" rows="4" maxlength="" class="ywapo_input ywapo_input_textarea ywapo_price_fixed"></textarea>
<input onclick="InsertText('18','Ş')" value=" Ş " type="button">
<input onclick="InsertText('18','Ş')" value=" @ " type="button">
<input onclick="InsertText('18','Ş')" value=" # " type="button">

Answer

This should help you..

$('button').click(function(e) {
  var input = $('.ywapo_input')
  input.val(input.val() + e.target.value)
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea data-typeid="18" data-price="15" data-pricetype="fixed" data-index="0" name="ywapo_textarea_18[0]" cols="20" rows="4" maxlength="" class="ywapo_input ywapo_input_textarea ywapo_price_fixed"></textarea>
<br/>
<button value="$">$</button>
<button value="@">@</button>
<button value="#">#</button>

Comments