2010-01-14 6 views
0

URL의 #에 따라 요소에 쿼리 UI 효과를 적용하고 싶습니다.URL에서 #name 요소에 jquery UI 효과를 적용하는 방법

예 : www.mysite.com/page.html#name을로드 할 때 #name을 사용하여 요소에 effect()를 적용하면 www.mysite.com/page.html#othername을로드 할 때 효과가 발생합니다 () #othername id 및 www.mysite.com/page03.html을 사용하여 요소에 적용하면 단순히 적용()되지 않습니다.

답변

0

당신은 # 기호를 포함 # 기호를 다음 URL의 일부를 얻을 수

window.location.hash를 사용할 수 있습니다. 이 #name를 반환합니다

는 귀하의 경우에는

window.location를 참조하십시오.

$(function(){ 
    $("#btn1").click(function(){ 
     var elemName = window.location.hash; 
     /* $(elemName) will retrieve the jQuery element with the corresponding 
       id and you can apply the effect to this element.*/ 
    }); 
}); 
+0

그것은 매력 감사처럼 작동합니다! – LapinLove404

관련 문제