Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 따라다니는 배너
- 시놀로지
- PHP GCM
- utf-8
- 커널
- form
- RTL88x2BU
- ajax
- Injection
- readonly
- jQuery
- disabled
- AC1300
- javascript
- SQL Injection
- 무선랜카드
- DS718+
- println
- synology
- XMLHTTP
- lsusb
- ASP
- Getrows
- FileSystemObject
- submit
- jquery 레이어
- euc-kr
- replace
- 크로스 컴파일
- include
Archives
- Today
- Total
아는 것이 좋은 것이다.
[jQuery] 동적테이블 생성 삭제 계산 본문
<html> <head> <title>테스트 페이지</title> </head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script><!-- 최신버전 제이쿼리 --> <body> <table cellpadding='2' cellspacing='0' border="1" width="500"> <thead> <tr> <th>상품명</th> <th>가격</th> <th>개수</th> <th>합계</th> <th><input type="button" value="추가" id="itemAdd"/></th> </tr> </thead> <tbody id="AddOption"> </tbody> </table> <script type="text/javascript"> $('#itemAdd').click(function(){ //alert("aa"); var contents = ''; contents += '<tr>'; contents += '<td><input type="text" name="item_name" /></td>'; contents += '<td><input type="text" name="price" class="price" /></td>'; contents += '<td><input type="text" name="qty" class="qty" /></td>'; contents += '<td><input type="text" name="sumPrice" class="sumPrice" /></td>'; contents += '<td><input type="button" name="delRow" class="delRow" value=" X " /></td>'; contents += '</tr>'; $('#AddOption').append(contents); // 추가기능 $('.delRow').click(function(){ // 삭제기능 $(this).parent().parent().remove(); //alert("aaa"); }); $('.price, .qty, .sumPrice').keyup(function(){ $(this).val( $(this).val().replace(/[^0-9]/gi,"") ); //숫자만 입력가능 }); $('.price').keyup(function(){ var num = $(".price").index(this); $('.sumPrice').eq(num).val($('.price').eq(num).val() * $('.qty').eq(num).val()); }); $('.qty').keyup(function(){ var num = $(".qty").index(this); $('.sumPrice').eq(num).val($('.price').eq(num).val() * $('.qty').eq(num).val()); }); $('.sumPrice').keyup(function(){ var num = $(".sumPrice").index(this); $('.sumPrice').eq(num).val($('.price').eq(num).val() * $('.qty').eq(num).val()); }); }); </script> </body> </html>
'jQuery' 카테고리의 다른 글
[jQuery] 이메일 직접입력, select 선택입력 (0) | 2014.06.25 |
---|---|
[jQuery] 스크롤 상단으로 이동 (0) | 2014.06.21 |
[jQuery] radio 선택된 값 가져오기 (0) | 2014.06.12 |
[jQuery] jQuery 레이어 팝업, 마우스 위치에 창 띄우기 (3) | 2014.06.04 |
[jQuery] 따라다니는 배너 (0) | 2014.05.30 |
Comments