리자

클릭으로 수량 조절

· 2008-11-14 (금) 14:53:18 · 2879

간결함이 무기인데 기본이 없다보니 코드가 엉망입니다.

좀 줄여주세요. ^^



<input type=text name='ct_qty' id='ct_qty' value='1' size=4 maxlength=4 class=ed autocomplete='off' style='text-align:right;' onkeyup='calc_amount()'>
<img src='img/qty_control.gif' border=0 align=absmiddle usemap="#qty_control_map"> 개
<map name="qty_control_map">
<area shape="rect" coords="0, 0, 10, 9"   id='qty_plus'>
<area shape="rect" coords="0, 10, 10, 19" id='qty_minus'>
</map>

... 중략 ...


<script>
// 위,아래 이미지 클릭으로 수량 조절
$(document).ready(function() {
    var $this = $('#ct_qty');
    $('#qty_plus').click(function() {
        if (isNaN(parseInt($this.val()))) {
            $this.val(1);
        }
        else {
            $this.val(parseInt($this.val()) + 1);
        }
    }).css('cursor', 'pointer');

    $('#qty_minus').click(function() {
        if (isNaN(parseInt($this.val()))) {
            $this.val(1);
        }
        else {
            $this.val(parseInt($this.val()) - 1);
            if ($this.val() < 1) $this.val(1);
        }
    }).css('cursor', 'pointer');
});
</script>

[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
jQuery 08-12-13 조회 4,951
jQuery 08-12-12 조회 5,873
기타 08-12-12 조회 2,541
jQuery
[jQuery]
08-12-11 조회 3,289
기타 08-12-10 조회 3,562
MySQL 08-12-06 조회 3,761
MySQL 08-11-30 조회 4,023
jQuery 08-11-26 조회 5,123
jQuery 08-11-25 조회 3,806
jQuery 08-11-25 조회 3,140
jQuery 08-11-25 조회 5,960
jQuery 08-11-25 조회 5,020
jQuery 08-11-21 조회 5,628
JavaScript 08-11-21 조회 5,354
기타 08-11-20 조회 4,182
jQuery 08-11-20 조회 4,263
jQuery 08-11-19 조회 4,417
jQuery 08-11-19 조회 4,716
jQuery 08-11-18 조회 4,430
jQuery 08-11-15 조회 2,897
기타 08-11-14 조회 3,013
JavaScript 08-11-14 조회 2,880
jQuery 08-11-14 조회 3,683
jQuery 08-11-13 조회 4,400
jQuery 08-11-12 조회 1.2만
기타 08-11-07 조회 1.1만
JavaScript 08-11-03 조회 3,422
PHP 08-11-01 조회 3,117
기타 08-10-30 조회 3,055
JavaScript 08-10-30 조회 2,488