티스토리 뷰
이 시도:
<?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
댓글