Skip to content

Instantly share code, notes, and snippets.

@evansantos
Created February 26, 2014 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansantos/9234223 to your computer and use it in GitHub Desktop.
Save evansantos/9234223 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<textarea cols="40" rows="6"></textarea>
<div class="btn-group">
<button type="button" class="btn btn-default" value=" aah ">Left</button>
<button type="button" class="btn btn-default" value="bbh">Middle</button>
<button type="button" class="btn btn-default" value="cch">Right</button>
<button type="button" class="btn btn-default" value="ddh">Top</button>
<button type="button" class="btn btn-default">Bottom</button>
<button type="button" class="btn btn-default">Top-Left</button>
</div>
</body>
</html>
$('.btn').on("click",function(){
var content = $.trim($("textarea").val());
if(content === "" && content === null){
$("textarea").focus().val($(this).val()+" ");
}else{
$("textarea").focus().val(content+" "+$(this).val()+" ");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment