2011-09-30 3 views
0
<li><label>Email:</label> <input type='text' name='username' 
          id="forgot_username" /></li> 
         <li><label>&nbsp;</label> <input type="submit" 
          id="forgot_btn" value="Send Reminder" class="btn"></li> 

위의 텍스트 상자와 버튼이 jsp에 있습니다. 그리고 아래의 조건, 내가 원하는 것은이 조건이 발생할 때, 텍스트 상자 위에 있고 버튼은 내가 어떻게 할 수 있는지 숨겨야한다는 것입니다.자바 스크립트를 사용하여 jsp 파일의 요소를 숨기는 방법

<c:if test="${param.message == 3}"> 

    <script> 
     $('#hide').hide(); 
    </script> 

    <span class="error"><font color="red"> Email does not match</font></span> 
</c:if> 

답변

0

왜 당신이 그 <li> 요소를 넣을 수 없습니다

<div id="hide"> 
    <ol> 
     <li> 
      <label>Email:</label> 
      <input type='text' name='username' id="forgot_username" /> 
     </li> 
     <li> 
      <label>&nbsp;</label> 
      <input type="submit" id="forgot_btn" value="Send Reminder" class="btn"> 
     </li> 
    </ol> 
</div> 

을 그리고 당신은이 같은 숨길 수 :

<c:if test="${param.message == 3}"> 
         <span class="error"><font color="red"> Email does not match</font></span> 
        </c:if> 
1

이 같은 첫 번째 코드 주위에 div 태그를 넣어해야 동일한 구조 안에 있습니까?

당신이 함께 이러한 요소를 넣을 수 없습니다 및 상태를 반복하지 않으려면, 당신은 항상 새로운 변수를 정의 할 수 있습니다 :

<c:set var="condition" value="0"> 
<c:if test="${param.message == 3}"> 
    <c:set var="condition" value="1"> 
</c:if> 

<c:if test="${condition == 1}"> 
         <span class="error"><font color="red"> Email does not match</font></span> 
        </c:if> 

.... 

<c:if test="${condition == 1}"> 
<li><label>Email:</label> <input type='text' name='username' 
          id="forgot_username" /></li> 
         <li><label>&nbsp;</label> <input type="submit" 
          id="forgot_btn" value="Send Reminder" class="btn"></li> 
</c:if> 

<li>이 클라이언트가있는 경우에도 표시되지 않습니다 이런 식으로 JS가 사용 중지되었거나 JS 문제가 발생했습니다.

관련 문제