<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 식으로 하면 이렇게도 할 수 있겠습니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6730 |
|
11년 전 | 1112 | |
| 6729 | 11년 전 | 568 | ||
| 6728 |
|
11년 전 | 582 | |
| 6727 | 11년 전 | 2426 | ||
| 6726 | 11년 전 | 601 | ||
| 6725 |
네모웹에이전시
|
11년 전 | 447 | |
| 6724 |
네모웹에이전시
|
11년 전 | 890 | |
| 6723 | 11년 전 | 1026 | ||
| 6722 | 11년 전 | 968 | ||
| 6721 | 11년 전 | 653 | ||
| 6720 | 11년 전 | 1978 | ||
| 6719 | 11년 전 | 2199 | ||
| 6718 | 11년 전 | 1111 | ||
| 6717 |
|
11년 전 | 663 | |
| 6716 | 11년 전 | 2311 | ||
| 6715 | 11년 전 | 7581 | ||
| 6714 | 11년 전 | 2050 | ||
| 6713 | 11년 전 | 788 | ||
| 6712 |
geektoo
|
11년 전 | 1161 | |
| 6711 | 11년 전 | 904 | ||
| 6710 |
sirzzang
|
11년 전 | 2134 | |
| 6709 |
bewitched
|
11년 전 | 1804 | |
| 6708 |
levin
|
11년 전 | 573 | |
| 6707 | 11년 전 | 769 | ||
| 6706 | 11년 전 | 1801 | ||
| 6705 | 11년 전 | 994 | ||
| 6704 |
|
11년 전 | 759 | |
| 6703 | 11년 전 | 420 | ||
| 6702 | 11년 전 | 1102 | ||
| 6701 | 11년 전 | 808 | ||
| 6700 | 11년 전 | 1723 | ||
| 6699 | 11년 전 | 717 | ||
| 6698 |
이박사친구
|
11년 전 | 731 | |
| 6697 | 11년 전 | 1219 | ||
| 6696 | 11년 전 | 622 | ||
| 6695 |
Header
|
11년 전 | 708 | |
| 6694 | 11년 전 | 1165 | ||
| 6693 |
|
11년 전 | 1116 | |
| 6692 | 11년 전 | 1153 | ||
| 6691 | 11년 전 | 1289 | ||
| 6690 |
|
11년 전 | 721 | |
| 6689 | 11년 전 | 898 | ||
| 6688 | 11년 전 | 938 | ||
| 6687 | 11년 전 | 542 | ||
| 6686 |
RGB255
|
11년 전 | 964 | |
| 6685 |
|
11년 전 | 645 | |
| 6684 | 11년 전 | 722 | ||
| 6683 | 11년 전 | 389 | ||
| 6682 | 11년 전 | 1134 | ||
| 6681 | 11년 전 | 1424 | ||
| 6680 | 12년 전 | 460 | ||
| 6679 |
RGB255
|
12년 전 | 399 | |
| 6678 | 12년 전 | 1353 | ||
| 6677 |
|
12년 전 | 445 | |
| 6676 | 12년 전 | 1018 | ||
| 6675 |
디자이너필이
|
12년 전 | 828 | |
| 6674 | 12년 전 | 1243 | ||
| 6673 | 12년 전 | 1315 | ||
| 6672 | 12년 전 | 6034 | ||
| 6671 | 12년 전 | 1342 | ||
| 6670 |
하프의정령
|
12년 전 | 575 | |
| 6669 | 12년 전 | 418 | ||
| 6668 |
공부하고가겠슴다
|
12년 전 | 464 | |
| 6667 |
하프의정령
|
12년 전 | 553 | |
| 6666 | 12년 전 | 790 | ||
| 6665 | 12년 전 | 1415 | ||
| 6664 | 12년 전 | 935 | ||
| 6663 | 12년 전 | 1160 | ||
| 6662 | 12년 전 | 414 | ||
| 6661 |
basketball
|
12년 전 | 514 | |
| 6660 | 12년 전 | 2513 | ||
| 6659 | 12년 전 | 1616 | ||
| 6658 |
|
12년 전 | 1340 | |
| 6657 |
|
12년 전 | 3160 | |
| 6656 | 12년 전 | 566 | ||
| 6655 |
프로프리랜서
|
12년 전 | 2336 | |
| 6654 |
프로프리랜서
|
12년 전 | 1915 | |
| 6653 |
프로프리랜서
|
12년 전 | 1749 | |
| 6652 |
프로프리랜서
|
12년 전 | 1835 | |
| 6651 |
|
12년 전 | 786 | |
| 6650 | 12년 전 | 1319 | ||
| 6649 | 12년 전 | 1320 | ||
| 6648 | 12년 전 | 814 | ||
| 6647 | 12년 전 | 3164 | ||
| 6646 | 12년 전 | 474 | ||
| 6645 | 12년 전 | 968 | ||
| 6644 |
BBAYOUNG
|
12년 전 | 1393 | |
| 6643 | 12년 전 | 1804 | ||
| 6642 | 12년 전 | 650 | ||
| 6641 | 12년 전 | 1341 | ||
| 6640 | 12년 전 | 718 | ||
| 6639 | 12년 전 | 2322 | ||
| 6638 |
jasmin2
|
12년 전 | 759 | |
| 6637 |
geektoo
|
12년 전 | 447 | |
| 6636 | 12년 전 | 669 | ||
| 6635 |
프로프리랜서
|
12년 전 | 2235 | |
| 6634 |
프로프리랜서
|
12년 전 | 1743 | |
| 6633 |
프로프리랜서
|
12년 전 | 4060 | |
| 6632 |
프로프리랜서
|
12년 전 | 1350 | |
| 6631 |
프로프리랜서
|
12년 전 | 1789 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기