2011-09-05 4 views
3

이전에 작동하는 웹 사이트에서 작은 jQuery 스크립트를 사용하여 클래스 콘텐츠 슬라이드가있는 이미지를 트리거하고 마우스를 가져 가면 애니메이션으로 나타나고 클릭하면 콘텐츠가 포함 된 div가 표시되고 다시 클릭하면 숨겨집니다. . 이것은 내 메인 페이지 (예 : index.html)에서 제대로 작동하지만 하위 디렉토리 페이지 (예 : subdir/code/howcssworks.html)에서는 작동하지 않으며 상대 링크 경로가 더 이상 작동하지 않기 때문이라고 가정합니다.관련 링크가있는 jQuery 콘텐츠 슬라이더

다음은 jQuery 스크립트입니다.

$(document).ready(function() { 

var slideState = "closed"; 

$('div.content').hide(); 

$('img.contentslide').click(function() { 
    $('div.content').toggle(1500,function() { 
     if (jQuery.browser.msie) {       // Lines 15-17 = special treatment for IE, because of 
      this.style.removeAttribute('filter');   // lack of support for ClearType font rendering on items 
     }             // being toggled in jQuery. 
    }); 
     if (slideState == 'closed') { 
      $('img.contentslide').attr('src','images/website/hidecontentstd.png'); 
      slideState = "open";  

     } else { 
      $('img.contentslide').attr('src','images/website/showcontentstd.png'); 
      slideState = "closed"; 
     } 
}); 

$('img.contentslide').hover(function() { 
    if (slideState == 'closed') { 
     $(this).attr('src','images/website/showcontenthvr.png'); 

    } else { 
     $(this).attr('src','images/website/hidecontenthvr.png'); 
    } 
}, 
function() { 
    if (slideState == 'open') { 
     $(this).attr('src','images/website/hidecontentstd.png'); 

    } else { 
     $(this).attr('src','images/website/showcontentstd.png'); 
    } 
} 
); 

return false; // If JS is disabled - show extra content automatically 

}); 

내 질문은 : 그것은 메인 페이지와 내 웹 사이트의 하위 페이지 모두 제대로 작동 그래서 내가 jQuery를 스크립트에서 상대 연결 경로를 변경하는 방법? 대신이 같은 링크의

답변

0

:

images/website/hidecontentstd.png 

이 필요합니다 당신의 images 폴더 yoursite.com/images

에 있다고 가정

/images/website/hidecontentstd.png