티스토리 뷰

이 시도:

<?php
if(condition) {
    ?>
        <script>//JS Code</script>
            <?php
            }
            ?>
            

페이지를로드 할 때 조건이 true이면 스크립트 태그 사이의 js 코드가 실행되며 코드를 작성하는 대신 다른 js 파일을 연결할 수도 있습니다.

-------------------

내 문제를 해결했습니다. 방금 JS 기능을 변경했습니다.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script type="text/javascript">

    //table fri
        $("#fri input[type='radio']").change(function(){
                var count = $("#fri input[type='radio']:checked").length;
                        if(count>3){
                                    $(this).prop('checked', false);
                                              alert("You cannot add more than 3");
                                                      }
                                                          });
                                                          
                                                              //table sat
                                                                  $("#sat input[type='radio']").change(function(){
                                                                          var count = $("#sat input[type='radio']:checked").length;
                                                                                  if(count>3){
                                                                                              $(this).prop('checked', false);
                                                                                                        alert("You cannot add more than 3");
                                                                                                                }
                                                                                                                    });
                                                                                                                    
                                                                                                                        //refresh selection
                                                                                                                            $(".refresh").click(function(){
                                                                                                                                    $("input[type='radio']").prop('checked', false);
                                                                                                                                        });
                                                                                                                                        


출처
https://stackoverflow.com/questions/39940180
댓글
공지사항
Total
Today
Yesterday
«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30