开发者

send the value of id to fancy box

I have different value for id attribute that I need to send to fancy box.

$('a.Links').cli开发者_Go百科ck(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'
});  

How can I send the value of clickID to .fancy box. I tried to add the .fancybox within click function but that doesnt work. see previous question for detail

the index value of attribute


Suppose all of your IDs begin with the word 'popup_', (popup_1,popup_2 etc.), then you could use the Attribute Starts With selector like this:

// 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'
});

However, it would be more straightforward to use a class attribute to address them collectively, like this:

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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜