리자

클릭으로 수량 조절

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

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

좀 줄여주세요. ^^



<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,969
jQuery 08-12-12 조회 5,884
기타 08-12-12 조회 2,551
jQuery
[jQuery]
08-12-11 조회 3,298
기타 08-12-10 조회 3,572
MySQL 08-12-06 조회 3,771
MySQL 08-11-30 조회 4,035
jQuery 08-11-26 조회 5,135
jQuery 08-11-25 조회 3,823
jQuery 08-11-25 조회 3,148
jQuery 08-11-25 조회 5,974
jQuery 08-11-25 조회 5,041
jQuery 08-11-21 조회 5,645
JavaScript 08-11-21 조회 5,359
기타 08-11-20 조회 4,194
jQuery 08-11-20 조회 4,276
jQuery 08-11-19 조회 4,431
jQuery 08-11-19 조회 4,727
jQuery 08-11-18 조회 4,443
jQuery 08-11-15 조회 2,911
기타 08-11-14 조회 3,024
JavaScript 08-11-14 조회 2,890
jQuery 08-11-14 조회 3,693
jQuery 08-11-13 조회 4,413
jQuery 08-11-12 조회 1.2만
기타 08-11-07 조회 1.1만
JavaScript 08-11-03 조회 3,434
PHP 08-11-01 조회 3,127
기타 08-10-30 조회 3,063
JavaScript 08-10-30 조회 2,497