<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개
<!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 전달할여 사용할수 있습니다.
열매님의 소스를 조금 수정했습니다.^^
약간 다르게 해보자면 ^^
[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 식으로 하면 이렇게도 할 수 있겠습니다
게시글 목록
| 번호 | 제목 |
|---|---|
| 32341 | |
| 32339 | |
| 32326 | |
| 32325 | |
| 32322 | |
| 32319 | |
| 32318 | |
| 32316 | |
| 32315 | |
| 32313 | |
| 32312 | |
| 32311 | |
| 32310 | |
| 32304 | |
| 32303 | |
| 32300 | |
| 32293 | |
| 32292 | |
| 32291 | |
| 32285 | |
| 32284 | |
| 32275 | |
| 32271 | |
| 32268 | |
| 32265 | |
| 32261 | |
| 32258 | |
| 32257 | |
| 32255 | |
| 32254 | |
| 32253 | |
| 32251 | |
| 32250 | |
| 32249 | |
| 32247 | |
| 32246 | |
| 32245 | |
| 32244 | |
| 32243 | |
| 32242 | |
| 32241 | |
| 32240 | |
| 32239 | |
| 32238 | |
| 32237 | |
| 32236 | |
| 32232 | |
| 32229 | |
| 32228 | |
| 32227 | |
| 32217 | |
| 32215 | |
| 32214 | |
| 32213 | |
| 32211 | |
| 32207 | |
| 32196 | |
| 32193 | |
| 32192 | |
| 32190 | |
| 32188 | |
| 32186 | |
| 32184 | |
| 32173 | |
| 32172 | |
| 32171 | |
| 32167 | |
| 32165 | |
| 32163 | |
| 32162 | |
| 32158 | |
| 32157 | |
| 32155 | |
| 32151 | |
| 32149 | |
| 32135 | |
| 32132 | |
| 32127 | |
| 32125 | |
| 32122 | |
| 32120 | |
| 32119 | |
| 32117 | |
| 32116 | |
| 32115 | |
| 32114 | |
| 32112 | |
| 32111 | |
| 32109 | |
| 32107 | |
| 32104 | |
| 32103 | |
| 32102 | |
| 32101 | |
| 32094 | |
| 32089 | |
| 20404 | |
| 31036 | |
| 8279 | |
| 8268 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기