<style>
.__keyinp {width:100%;box-sizing:border-box;border:1px solid #ddd;height:30px;text-indent:10px;margin-bottom:10px;font-size:14px;}
.__keyboard {width:100%;}
.__keyboard tr > * {border:1px solid #ddd;text-align:center;}
.__keyboard button {display:block;padding:5px 0;font-family:D2coding,sans-serif;box-sizing:border-box;width:50px;border:none;background:none;}
</style>

<div style="width:500px;">
	<input type="text" class="__keyinp">
	<table class="__keyboard">
		<tr>
			<td><button type="button" onclick="addkey(this,'Q');">Q</button></td>
			<td><button type="button" onclick="addkey(this,'W');">W</button></td>
			<td><button type="button" onclick="addkey(this,'E');">E</button></td>
			<td><button type="button" onclick="addkey(this,'R');">R</button></td>
			<td><button type="button" onclick="addkey(this,'T');">T</button></td>
			<td><button type="button" onclick="addkey(this,'Y');">Y</button></td>
			<td><button type="button" onclick="addkey(this,'U');">U</button></td>
			<td><button type="button" onclick="addkey(this,'I');">I</button></td>
			<td><button type="button" onclick="addkey(this,'O');">O</button></td>
			<td><button type="button" onclick="addkey(this,'P');">P</button></td>
		</tr>
		<tr>
			<td><button type="button" onclick="addkey(this,'A');">A</button></td>
			<td><button type="button" onclick="addkey(this,'S');">S</button></td>
			<td><button type="button" onclick="addkey(this,'D');">D</button></td>
			<td><button type="button" onclick="addkey(this,'F');">F</button></td>
			<td><button type="button" onclick="addkey(this,'G');">G</button></td>
			<td><button type="button" onclick="addkey(this,'H');">H</button></td>
			<td><button type="button" onclick="addkey(this,'J');">J</button></td>
			<td><button type="button" onclick="addkey(this,'K');">K</button></td>
			<td><button type="button" onclick="addkey(this,'L');">L</button></td>
			<td></td>
		</tr>
		<tr>
			<td><button type="button" onclick="addDel(this,'1');">-</button></td>
			<td><button type="button" onclick="addDel(this,'all');">ALL</button></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
	</table>
</div>

<script>
function addkey(a,b){
	var txt = $('.__keyinp').val();
	$('.__keyinp').val(txt+b);
}
function addDel(a,b){
	if(b=='all'){
		$('.__keyinp').val('');
	}else{
		var txt = $('.__keyinp').val();
		$('.__keyinp').val(txt.slice(0,-1));
	}
}
</script>

'PROGRAM > JQUERY' 카테고리의 다른 글

반응형 팝업 및 24시간 적용  (0) 2018.11.16
~이상 ~이하 선택자  (0) 2018.05.03
우클릭 드래그 금지  (0) 2018.04.26
파일 추가 삭제  (0) 2018.04.26
jQuery 카운트 다운  (0) 2018.04.25