<input type="text" name="line" class="cntA1" value="1">
<input type="text" name="line" class="cntA2" value="2">
<input type="text" name="line" class="cntA3" value="3">
<input type="text" name="line" class="cntA4" value="4">
<input type="text" name="line" class="cntA2" value="2">
<input type="text" name="line" class="cntA3" value="3">
<input type="text" name="line" class="cntA4" value="4">
<a href="javascript:void(0);" onclick="cnt_plus();return false;">1 더하기</a>
<script type="text/javascript">
function cnt_plus() {
var cnt = $("input:text[name='line']").length;
for(var i=1; i<=cnt;i++) {
var scd = $(".cntA"+i).val();
var cc = parseInt(scd) + 1;
$(".cntA"+i).val(cc);
}
}
</script>
function cnt_plus() {
var cnt = $("input:text[name='line']").length;
for(var i=1; i<=cnt;i++) {
var scd = $(".cntA"+i).val();
var cc = parseInt(scd) + 1;
$(".cntA"+i).val(cc);
}
}
</script>
댓글 4개
11년 전
증가는 되지만 값을 사용하기에는 아니네요..
값을 사용하려면 그래도
class 값이 같으면 되잖아요..
값을 사용하려면 그래도
class 값이 같으면 되잖아요..
11년 전
제가 만든건 그냥 input 의value 값을 한번에 +1 시키는 방법입니다.
다른 좋은 방법있으시면 부탁드립ㄴ디ㅏ. ^^
다른 좋은 방법있으시면 부탁드립ㄴ디ㅏ. ^^
11년 전
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<input type="text" name="line1" class="cntA1 line" value="1">
<input type="text" name="line2" class="cntA2 line" value="2">
<input type="text" name="line3" class="cntA3 line" value="3">
<input type="text" name="line4" class="cntA4 line" value="4">
<a href="javascript:void(0);" onclick="cnt_plus();return false;">1 더하기</a>
<script type="text/javascript">
function cnt_plus() {
var cnt = $(".line").length;
for(var i=1; i<=cnt;i++) {
var scd = $(".cntA"+i).val();
var cc = parseInt(scd) + 1;
$(".cntA"+i).val(cc);
}
}
</script>
</body>
</html>
이렇게 하면 4개 의 input 전달할여 사용할수 있습니다.
열매님의 소스를 조금 수정했습니다.^^
<html lang="en">
<head>
<meta charset="utf-8">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<input type="text" name="line1" class="cntA1 line" value="1">
<input type="text" name="line2" class="cntA2 line" value="2">
<input type="text" name="line3" class="cntA3 line" value="3">
<input type="text" name="line4" class="cntA4 line" value="4">
<a href="javascript:void(0);" onclick="cnt_plus();return false;">1 더하기</a>
<script type="text/javascript">
function cnt_plus() {
var cnt = $(".line").length;
for(var i=1; i<=cnt;i++) {
var scd = $(".cntA"+i).val();
var cc = parseInt(scd) + 1;
$(".cntA"+i).val(cc);
}
}
</script>
</body>
</html>
이렇게 하면 4개 의 input 전달할여 사용할수 있습니다.
열매님의 소스를 조금 수정했습니다.^^
11년 전
약간 다르게 해보자면 ^^
[code]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<input type="text" name="line1" class="line" value="1">
<input type="text" name="line2" class="line" value="2">
<input type="text" name="line3" class="line" value="3">
<input type="text" name="line4" class="line" value="4">
<a href="#add_one" id="btn_add">1 더하기</a>
<script type="text/javascript">
$('#btn_add').click(function(evt) {
$('.line').each(function(idx, ele) {
$(ele).val(parseInt($(ele).val())+1);
});
evt.preventDefault();
});
</script>
</body>
</html>
[/code]
이왕 jquery 사용하는 김에.. 좀더 jquery 식으로 하면 이렇게도 할 수 있겠습니다
[code]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<input type="text" name="line1" class="line" value="1">
<input type="text" name="line2" class="line" value="2">
<input type="text" name="line3" class="line" value="3">
<input type="text" name="line4" class="line" value="4">
<a href="#add_one" id="btn_add">1 더하기</a>
<script type="text/javascript">
$('#btn_add').click(function(evt) {
$('.line').each(function(idx, ele) {
$(ele).val(parseInt($(ele).val())+1);
});
evt.preventDefault();
});
</script>
</body>
</html>
[/code]
이왕 jquery 사용하는 김에.. 좀더 jquery 식으로 하면 이렇게도 할 수 있겠습니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 9년 전 | 441 | ||
| 7829 |
|
9년 전 | 625 | |
| 7828 | 10년 전 | 554 | ||
| 7827 | 10년 전 | 451 | ||
| 7826 | 10년 전 | 454 | ||
| 7825 | 10년 전 | 494 | ||
| 7824 | 10년 전 | 457 | ||
| 7823 | 10년 전 | 403 | ||
| 7822 | 10년 전 | 377 | ||
| 7821 | 10년 전 | 323 | ||
| 7820 | 10년 전 | 359 | ||
| 7819 |
|
10년 전 | 756 | |
| 7818 | 10년 전 | 405 | ||
| 7817 | 10년 전 | 540 | ||
| 7816 | 10년 전 | 423 | ||
| 7815 | 10년 전 | 621 | ||
| 7814 | 10년 전 | 450 | ||
| 7813 | 10년 전 | 400 | ||
| 7812 | 10년 전 | 413 | ||
| 7811 | 10년 전 | 404 | ||
| 7810 | 10년 전 | 584 | ||
| 7809 | 10년 전 | 517 | ||
| 7808 | 10년 전 | 393 | ||
| 7807 | 10년 전 | 423 | ||
| 7806 |
프로그래머7
|
10년 전 | 1348 | |
| 7805 | 10년 전 | 1290 | ||
| 7804 |
zahir1312
|
10년 전 | 790 | |
| 7803 |
|
10년 전 | 1386 | |
| 7802 | 10년 전 | 475 | ||
| 7801 | 10년 전 | 871 | ||
| 7800 | 10년 전 | 1092 | ||
| 7799 | 10년 전 | 572 | ||
| 7798 | 10년 전 | 527 | ||
| 7797 | 10년 전 | 529 | ||
| 7796 | 10년 전 | 371 | ||
| 7795 | 10년 전 | 525 | ||
| 7794 | 10년 전 | 573 | ||
| 7793 | 10년 전 | 1069 | ||
| 7792 | 10년 전 | 491 | ||
| 7791 | 10년 전 | 572 | ||
| 7790 | 10년 전 | 521 | ||
| 7789 |
fbastore
|
10년 전 | 1459 | |
| 7788 | 10년 전 | 561 | ||
| 7787 | 10년 전 | 419 | ||
| 7786 | 10년 전 | 612 | ||
| 7785 | 10년 전 | 605 | ||
| 7784 | 10년 전 | 657 | ||
| 7783 | 10년 전 | 467 | ||
| 7782 | 10년 전 | 507 | ||
| 7781 | 10년 전 | 912 | ||
| 7780 | 10년 전 | 833 | ||
| 7779 | 10년 전 | 782 | ||
| 7778 | 10년 전 | 371 | ||
| 7777 | 10년 전 | 477 | ||
| 7776 | 10년 전 | 471 | ||
| 7775 | 10년 전 | 418 | ||
| 7774 | 10년 전 | 637 | ||
| 7773 | 10년 전 | 394 | ||
| 7772 | 10년 전 | 751 | ||
| 7771 | 10년 전 | 404 | ||
| 7770 | 10년 전 | 656 | ||
| 7769 | 10년 전 | 405 | ||
| 7768 | 10년 전 | 626 | ||
| 7767 | 10년 전 | 1187 | ||
| 7766 | 10년 전 | 503 | ||
| 7765 | 10년 전 | 553 | ||
| 7764 |
잘살아보자
|
10년 전 | 413 | |
| 7763 |
|
10년 전 | 1474 | |
| 7762 |
Tosea
|
10년 전 | 1073 | |
| 7761 | 10년 전 | 666 | ||
| 7760 |
잘살아보자
|
10년 전 | 702 | |
| 7759 |
잘살아보자
|
10년 전 | 534 | |
| 7758 |
잘살아보자
|
10년 전 | 611 | |
| 7757 | 10년 전 | 1252 | ||
| 7756 |
ITBANK
|
10년 전 | 1268 | |
| 7755 | 10년 전 | 1936 | ||
| 7754 | 10년 전 | 1071 | ||
| 7753 | 10년 전 | 897 | ||
| 7752 | 10년 전 | 1409 | ||
| 7751 |
잘살아보자
|
10년 전 | 553 | |
| 7750 |
잘살아보자
|
10년 전 | 490 | |
| 7749 |
잘살아보자
|
10년 전 | 502 | |
| 7748 |
잘살아보자
|
10년 전 | 518 | |
| 7747 |
잘살아보자
|
10년 전 | 604 | |
| 7746 |
잘살아보자
|
10년 전 | 689 | |
| 7745 |
잘살아보자
|
10년 전 | 929 | |
| 7744 |
잘살아보자
|
10년 전 | 429 | |
| 7743 | 10년 전 | 959 | ||
| 7742 |
starbros
|
10년 전 | 852 | |
| 7741 |
잘살아보자
|
10년 전 | 684 | |
| 7740 |
잘살아보자
|
10년 전 | 558 | |
| 7739 |
잘살아보자
|
10년 전 | 474 | |
| 7738 |
잘살아보자
|
10년 전 | 550 | |
| 7737 |
잘살아보자
|
10년 전 | 521 | |
| 7736 |
잘살아보자
|
10년 전 | 540 | |
| 7735 |
잘살아보자
|
10년 전 | 867 | |
| 7734 |
잘살아보자
|
10년 전 | 438 | |
| 7733 |
잘살아보자
|
10년 전 | 554 | |
| 7732 |
잘살아보자
|
10년 전 | 712 | |
| 7731 |
잘살아보자
|
10년 전 | 630 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기