본문 바로가기

jQuery

[jQuery]테이블의 행 추가/삭제 구현하기

http://rcnboys.blog.me/20117878562 - 퍼온곳


나와는 다른 스타일 발견


<script type="text/javascript" src="/js/jquery-1.3.2.js"></script>

<script language="JavaScript">
 ## 행 추가
 function addRow(){
  var template = $("#template");
  $("#MainTable").append($(template).val());
 }
 
 ## 행 삭제
 function deleteRow(obj){
  $(obj).parent().remove();
 } 
</script>

 

<body>

  <table id="MainTable">

  </table>

</body>

 

<textarea id="template" style="display:none;">
<tr>
    <td>1</td>
    <td onclick="deleteRow(this);" style="cursor:hand;">2</td>
</tr>
</textarea>

'jQuery' 카테고리의 다른 글

JSONP  (0) 2013.06.27
드래그 방지 퍼옴  (0) 2013.05.24
차트 만들기 라이브러리  (0) 2012.03.27
ebook 스타일로 만들어주는 jQuery 라이브러리  (0) 2012.03.27
jQuery 속도 개선에 대한 좋은 문서  (0) 2011.11.03