.addClass / .removeClass

easyliving·2023년 2월 5일
0

FRONT_END (JAVA_SCRIPT)

목록 보기
27/55
<style>
.onIdCheck{color:blue; font-weight: 600;}
.offIdCheck{color:red; font-weight: 600;}
</style>


<script>
  success:function(data){
    	  		console.log(data[0].result);
    	  		if(data[0].result=='Id-Usable'){
    	  			$("#checkTxt").addClass("onIdCheck");
    	  			$("#checkTxt").removeClass("offIdCheck");
    	  			$("#checkTxt").text("사용가능한 아이디 입니다.");
    	  			idFlag=true;
    	  		}else{
    	  			$("#checkTxt").addClass("offIdCheck");
    	  			$("#checkTxt").removeClass("onIdCheck");
    	  			$("#checkTxt").text("아이디를 사용할 수 없습니다.");
    	  			idFlag=false;
    	  		}
    	  	},
</script>

<body>
  			<tr>
               <th>아이디</th>
               <td>
                  <input type="text" name="id" id="id">
                  <button type="button" id="checkId" onclick="checkIdBtn()">중복확인</button>
                  <span id="checkTxt">ID중복확인을 해주세요</span>
               </td>
            </tr>
</body>  

profile
가끔져요

0개의 댓글