2013-04-04 5 views
0

나는 아무것도하지 않으려 고합니다 ... 특정 체크 박스 상태가 변경 될 때 "noshowuntilchangevelocity"클래스의 내용이 표시되거나 숨겨지기를 원합니다. 당신은 여기입니다 id="noshowuntilchangevelocity"style="display:none;" 당신은 display:none;를 사용할 필요가 체크 상자 상태 변경시 텍스트 토글

  • 하지 display:hidden;
  • 사이에 공백을 추가 할 필요가

    • :

      $(document).ready(function() 
          { 
      
          $("input#velocity").change(function() 
           { 
            $('#noshowuntilchangevelocity').toggle(); 
           }); 
      
      }); 
      <input id="velocity" name="velocity" type="checkbox"value="Y" checked> 
      <div id="noshowuntilchangevelocity"style="display: hidden;"> 
      <p class="bolder">You are changing this selection</p> 
      </div> 
      
    +0

    JsFiddle 링크를 추가하고 질문하기. –

    +0

    jQuery의 버전은 무엇입니까? – hjpotter92

    +0

    그것이 그대로 작동하고 있습니다. http://jsfiddle.net/ZJmw3/ – hjpotter92

    답변

    0

    나는 당신이 두 개의 작은 오류가 있다고 생각 올바른 버전 :

    <input id="velocity" name="velocity" type="checkbox" value="Y" checked> 
    <div id="noshowuntilchangevelocity" style="display: none;"> 
        <p class="bolder">You are changing this selection</p> 
    </div> 
    
    0
    $(document).ready(function() 
        { 
        $('#noshowuntilchangevelocity').hide() 
        $("input#velocity").change(function() 
         { 
          $('#noshowuntilchangevelocity').toggle(); 
         }); 
    
    }); 
    <input id="velocity" name="velocity" type="checkbox" value="Y" checked> 
    <div id="noshowuntilchangevelocity"> 
        <p class="bolder">You are changing this selection</p> 
    </div> 
    

    또는 Steve의 솔루션도 잘 작동합니다.

    +0

    문자 그대로 정확히 몇 분 전에 받았던 것입니다. 여전히 작동하지 않습니다. 이 사이트에는 나뭇 가지와 부트 스트랩이 있습니다. 거기에는 몇 가지 조건문이 있습니다. 아직 작동하지 않기 때문에 제대로 닫히지 않아야합니다. –

    +0

    Chrome에서 열어 본 경우 요소를 확인하고 콘솔을 확인하십시오. 이 실행을 방해하는 전역 JS 예외가있을 수 있습니다. –

    0

    나는 모든 사람들의 대답과 원래의 코드가 모두 잘 작동했기 때문에 다시 튀어 나와 문제를 설명 할 것이라고 생각했다. 내가 부트 스트랩 파일을 두 번 포함했음을 알았습니다 (모달에 한 번, 원본 페이지에 한 번). 일단 내가 그걸 꺼냈다면 다시 행동으로 돌아갔습니다 :)

    모두에게 도움을 주셔서 감사합니다.