2010-11-19 3 views
1

멋진 상자로 보낼 필요가있는 id 속성의 값이 다릅니다.멋진 상자에 id의 값을 보냅니다.

$('a.Links').click(function() {       
    var clickID = $(this).attr('id') ; 
    alert(clickIDID); 
}); 

$("#"+clickID).fancybox({ 
    'width' : '75%', 
    'height' : '75%', 
    'autoScale' : false, 
    'transitionIn' : 'none', 
    'transitionOut' : 'none', 
    'type' : 'iframe', 
    'titlePosition' : 'outside', 
    'content' : 'testl' 
}); 

어떻게 .fancy 상자에 clickID의 값을 보낼 수 있습니까? 클릭 기능 내에서 .fancybox를 추가하려고했지만 그 기능은 작동하지 않습니다.
the index value of attribute

답변

3

은 가정하자 귀하의 ID의 모든 단어 'popup_'(popup_1, popup_2 등)로 시작 세부 사항에 대한 이전 질문을 참조하십시오 당신은이 같은 Attribute Starts With 선택을 사용할 수

// initialize fancybox for all elements with ID starting with 'popup_' 
$("[id^=popup_]").fancybox({ 
    'width' : '75%', 
    'height' : '75%', 
    'autoScale' : false, 
    'transitionIn' : 'none', 
    'transitionOut' : 'none', 
    'type' : 'iframe', 
    'titlePosition' : 'outside', 
    'content' : 'testl' 
}); 

그러나 다음과 같이 집합 적으로 클래스 속성을 사용하여 클래스 속성을 사용하는 것이 더 쉽습니다.

<a class="popup">Foo</a> 
<img class="popup" src="foo.jpg"/> 

$(".popup").fancybox({ 
    ... 
+0

문제는 제가 idexed 값을가집니다. 자세한 내용은 내 이전 quetion을 참조하십시오 – user512438

+0

http://stackoverflow.com/questions/4221269/the-index-value-of-attribute – user512438

+1

'$ ("a [id^= read]"). fancybox ({... 나는 뭔가를 놓치지 않는 한 그것을해야한다. 내가 설명한 것과 거의 같다. – karim79

관련 문제