성군님들 도와주세요....ㅠㅠ

성군님들 도와주세요....ㅠㅠ

QA

성군님들 도와주세요....ㅠㅠ

답변 4

본문

셀렉트박스 종류가 다른 3개가 있고 셀렉트박스를 눌렀을때 글자가 나타납니다.

"쿠폰 혜택"

이라는 글자가 셀렉트 박스를 선택했을때만 나와야 하는데,

다른 2번, 3번 셀렉트박스를 선택하면 "쿠폰 혜택" 글자가 없어집니다.

2번, 3번 셀렉트박스를 선택해도 글자가 안없어지는 방법은 없을까요?

 

참고로, 저는 퍼블리셔입니다.

자바스크립트 너무 어렵네요.. 열심히 공부하겠습니다..ㅠㅠ

 

 



$(function () {
        $(".coupon-tit").hide();
        $(".combobox").change(function () {
            var result = $(".combobox option:selected").val();
            if (result == "") {
                $(".coupon-tit").hide();
            } else {
                $(".coupon-tit").show();
            }
        });
    });
    $(document).ready(function () {
        $("#coupon-1").change(function () {
            var result = $("#coupon-1 option:selected").val();
            if (result == "") {
                $(".coupon-section-1").hide();
            } else {
                $(".coupon-section-1").show();
            }
        });
    });
    $(document).ready(function () {
        $("#coupon-2").change(function () {
            var result = $("#coupon-2 option:selected").val();
            if (result == "") {
                $(".coupon-section-2").hide();
                $(".coupon-tit").hide();
            } else {
                $(".coupon-section-2").show();
                $(".coupon-tit").show();
            }
        });
    });
    $(document).ready(function () {
        $("#coupon-3").change(function () {
            var result = $("#coupon-3 option:selected").val();
            if (result == "") {
                $(".coupon-section-3").hide();
            } else {
                $(".coupon-section-3").show();
            }
        });
    });

이 질문에 댓글 쓰기 :

답변 4


<!-- 셀렉트박스 쿠폰 관련 추가 -->
                                                <div class="select-box col-1 mo-col-1">
                                                    <div class="col__item">
                                                        <div class="select-box-wrap select__wrap custom-select-area select-box-flex" data-required="required">
                                                            <label for="room" class="input-title f-bold">객실권</label>
                                                            <div data-js="combobox" data-maxheight="200">
                                                                <select name="coupon-1" id="coupon-1" title="객실" class="combobox combobox--1 initial">
                                                                    <option value="">선택하세요.</option>
                                                                    <option value="1">리워즈 특별 1만원 할인</option>
                                                                    <option value="2">SPECIAL COUPON 신규 리워즈 2만원 할인</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="select-box col-1 mo-col-1">
                                                    <div class="col__item">
                                                        <div class="select-box-wrap select__wrap custom-select-area select-box-flex" data-required="required">
                                                            <label for="room" class="input-title f-bold">식음권</label>
                                                            <div data-js="combobox" data-maxheight="200">
                                                                <select name="coupon-2" id="coupon-2" title="식음" class="combobox combobox--1 initial">
                                                                    <option value="">선택하세요.</option>
                                                                    <option value="1">Welcome GIFT 아메리카노 교환권 (1잔)</option>
                                                                    <option value="2">Welcome GIFT 아메리카노 교환권 (2잔)</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="select-box col-1 mo-col-1">
                                                    <div class="col__item">
                                                        <div class="select-box-wrap select__wrap custom-select-area select-box-flex" data-required="required">
                                                            <label for="room" class="input-title f-bold">기타</label>
                                                            <div data-js="combobox" data-maxheight="200">
                                                                <select name="coupon-3" id="coupon-3" title="기타" class="combobox combobox--1 initial">
                                                                    <option value="">선택하세요.</option>
                                                                    <option value="1">기타1</option>
                                                                    <option value="2">기타2</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

    $(document).ready(function () {
        $("#coupon-2").change(function () {
            var result = $("#coupon-2 option:selected").val();
            if (result == "") {
                $(".coupon-section-2").hide();
                $(".coupon-tit").hide();
            } else {
                $(".coupon-section-2").show();
                $(".coupon-tit").show();
            }
        });
    });
   

->


    $(document).ready(function () {
        $("#coupon-2").change(function () {
            var result = $("#coupon-2 option:selected").val();
            if (result == "") {
                $(".coupon-section-2").hide();                
            } else {
                $(".coupon-section-2").show();                
            }
        });
    });
   
답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 946
© SIRSOFT
현재 페이지 제일 처음으로