Created
February 26, 2014 17:25
-
-
Save evansantos/9234223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.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