<li>글자추가 삭제

it/jQuery 2014. 8. 21. 12:05 Posted by 하얀나다

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>더하고 뺀다</title>
<script src="../lib/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
 var tf= $('#tt');
 var pl= $('#plus');
 var mi = $('#minus');
 var h = $('#ca');
 
 
 pl.click(function(){
  h.append('<li>'+tf.val()+'</li>');
 });
 mi.click(function(){
    $('li:last').remove();
 });
 
});
</script>
</head>
<body>
 <form name ="frm">
  <input type="text" id="tt">
  <input type="button" value="+" id="plus" >
  <input type="button"value="-" id="minus" >
   <br /> <br />
  <div id ="ca">[카테고리]
</div>
  
 </form>
</body>
</html>