<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 식으로 하면 이렇게도 할 수 있겠습니다
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7430 |
|
11년 전 | 4927 | |
| 7429 | 11년 전 | 1750 | ||
| 7428 |
멋진남자임
|
11년 전 | 1139 | |
| 7427 |
sdflksdj2
|
11년 전 | 792 | |
| 7426 | 11년 전 | 1336 | ||
| 7425 | 11년 전 | 1362 | ||
| 7424 | 11년 전 | 1029 | ||
| 7423 |
SeungYeon
|
11년 전 | 541 | |
| 7422 | 11년 전 | 786 | ||
| 7421 |
sdflksdj2
|
11년 전 | 659 | |
| 7420 | 11년 전 | 949 | ||
| 7419 |
|
11년 전 | 1374 | |
| 7418 |
멋진남자임
|
11년 전 | 1382 | |
| 7417 | 11년 전 | 584 | ||
| 7416 |
senseme
|
11년 전 | 1197 | |
| 7415 | 11년 전 | 941 | ||
| 7414 | 11년 전 | 694 | ||
| 7413 | 11년 전 | 4825 | ||
| 7412 | 11년 전 | 4393 | ||
| 7411 |
holla
|
11년 전 | 871 | |
| 7410 | 11년 전 | 4224 | ||
| 7409 | 11년 전 | 3914 | ||
| 7408 | 11년 전 | 4255 | ||
| 7407 | 11년 전 | 5043 | ||
| 7406 | 11년 전 | 4708 | ||
| 7405 | 11년 전 | 4271 | ||
| 7404 | 11년 전 | 731 | ||
| 7403 | 11년 전 | 5654 | ||
| 7402 | 11년 전 | 1484 | ||
| 7401 |
|
11년 전 | 951 | |
| 7400 | 11년 전 | 2956 | ||
| 7399 |
멋진남자임
|
11년 전 | 885 | |
| 7398 |
파랑새1597
|
11년 전 | 2644 | |
| 7397 | 11년 전 | 2241 | ||
| 7396 |
basketball
|
11년 전 | 1334 | |
| 7395 | 11년 전 | 1583 | ||
| 7394 | 11년 전 | 908 | ||
| 7393 | 11년 전 | 2046 | ||
| 7392 | 11년 전 | 824 | ||
| 7391 |
잘살아보자
|
11년 전 | 5339 | |
| 7390 |
잘살아보자
|
11년 전 | 2202 | |
| 7389 |
잘살아보자
|
11년 전 | 3304 | |
| 7388 |
파랑새1597
|
11년 전 | 906 | |
| 7387 | 11년 전 | 1081 | ||
| 7386 |
프리랜서퍼블리셔
|
11년 전 | 955 | |
| 7385 | 11년 전 | 1557 | ||
| 7384 |
울라라라우
|
11년 전 | 874 | |
| 7383 | 11년 전 | 1529 | ||
| 7382 |
잘살아보자
|
11년 전 | 4207 | |
| 7381 |
잘살아보자
|
11년 전 | 1971 | |
| 7380 |
잘살아보자
|
11년 전 | 1921 | |
| 7379 |
잘살아보자
|
11년 전 | 5883 | |
| 7378 |
senseme
|
11년 전 | 1859 | |
| 7377 |
잘살아보자
|
11년 전 | 2712 | |
| 7376 | 11년 전 | 2378 | ||
| 7375 |
잘살아보자
|
11년 전 | 1028 | |
| 7374 |
잘살아보자
|
11년 전 | 3132 | |
| 7373 |
잘살아보자
|
11년 전 | 2459 | |
| 7372 |
잘살아보자
|
11년 전 | 5822 | |
| 7371 |
잘살아보자
|
11년 전 | 3448 | |
| 7370 |
잘살아보자
|
11년 전 | 1895 | |
| 7369 |
잘살아보자
|
11년 전 | 2151 | |
| 7368 |
ksdhtm56
|
11년 전 | 529 | |
| 7367 | 11년 전 | 1403 | ||
| 7366 | 11년 전 | 911 | ||
| 7365 | 11년 전 | 3516 | ||
| 7364 |
잘살아보자
|
11년 전 | 1367 | |
| 7363 |
잘살아보자
|
11년 전 | 1336 | |
| 7362 |
잘살아보자
|
11년 전 | 1476 | |
| 7361 | 11년 전 | 3582 | ||
| 7360 | 11년 전 | 3537 | ||
| 7359 | 11년 전 | 3361 | ||
| 7358 |
멋진남자임
|
11년 전 | 1004 | |
| 7357 | 11년 전 | 3386 | ||
| 7356 | 11년 전 | 2584 | ||
| 7355 | 11년 전 | 3159 | ||
| 7354 |
파랑새1597
|
11년 전 | 626 | |
| 7353 |
잘살아보자
|
11년 전 | 2402 | |
| 7352 |
잘살아보자
|
11년 전 | 2390 | |
| 7351 |
잘살아보자
|
11년 전 | 2465 | |
| 7350 |
잘살아보자
|
11년 전 | 1444 | |
| 7349 |
잘살아보자
|
11년 전 | 1935 | |
| 7348 |
잘살아보자
|
11년 전 | 1258 | |
| 7347 |
잘살아보자
|
11년 전 | 1066 | |
| 7346 |
멋진남자임
|
11년 전 | 1630 | |
| 7345 | 11년 전 | 962 | ||
| 7344 | 11년 전 | 3845 | ||
| 7343 | 11년 전 | 3614 | ||
| 7342 | 11년 전 | 1240 | ||
| 7341 | 11년 전 | 2496 | ||
| 7340 |
|
11년 전 | 909 | |
| 7339 | 11년 전 | 1719 | ||
| 7338 | 11년 전 | 3326 | ||
| 7337 | 11년 전 | 3621 | ||
| 7336 | 11년 전 | 4550 | ||
| 7335 | 11년 전 | 948 | ||
| 7334 | 11년 전 | 1508 | ||
| 7333 | 11년 전 | 2911 | ||
| 7332 |
|
11년 전 | 1086 | |
| 7331 |
KeePin뽁이
|
11년 전 | 1078 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기