2010-03-08 4 views
1

다음과 같은 jQuery 코드 스 니펫은 Chrome 및 Opera에서 잘 작동하는 것으로 보이지만 관련 div를 숨기거나 표시 할 때 아무런 반응이 없습니다. Internet Explorer 또는 Firefox. 어떤 아이디어?jQuery hide/show div는 Opera/Chrome에서 작동하지만 IE/Firefox는 작동하지 않습니다.

$(function() { 
    $(".paste-meta-small .right a.collapse").click(function(event) { 
    $(this).parents(".paste-meta-small").next(".highlight").toggle(500); 
    $(this).text($(this).text() == 'show' ? 'hide' : 'show'); 
    event.preventDefault(); 
    }) 
}) 

$(function() { 
    $(".highlight-meta a.blog-collapse").click(function(event) { 
    $(this).parents(".highlight-meta").next(".blog-highlight").toggle(500); 
    $(this).text($(this).text() == 'show' ? 'hide' : 'show'); 
    var margin = ($(this).text() == "show" ? "15px" : "0"); 
    $(this).parents(".highlight-meta").css("margin-bottom", margin); 
    event.preventDefault(); 
    }) 
}) 

동작하는 예제가 사전에 here

감사를 찾을 수 있습니다

+1

무엇 당신의 HTML 모습입니까? (당신이 연결 한 페이지에서 내가 뭘보고 있어야하는지 이해가 안됩니다.) – Pointy

+0

console.log()를 사용하려고 했습니까? 이렇게하면 어디서 붙어 있는지 확인할 수 있습니다. – adardesign

+0

@ Pointy - ** ** 페이지입니다. 잠깐 나도 데려갔습니다. –

답변

1

귀하의 문제는 스크립트에 최고 최대 태그 :

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" /> 
<script src="/js/injekt.js" type="text/javascript"></script> 

두 번째 태그를로드하지 않습니다 다른 브라우저는 <script> 태그는 항상 닫는 태그가 필요하며 자동 닫을 수 없습니다.

<script></script> //Valid 
<script /> //Invalid 

변경이의 첫 번째 태그가 작동하게합니다 :

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
+0

아, 고마워요! 얼마나 어리석은 짓이야. 여기에 대한 첫 번째 질문은 실제 순간에 대한 답변입니다. 굉장해! 다시 감사합니다. –

+0

@injekt - 환영합니다! 그리고 SO에 오신 것을 환영합니다! –

관련 문제