Jquery 从链接rel属性设置fancybox宽度

Jquery 从链接rel属性设置fancybox宽度,jquery,fancybox,Jquery,Fancybox,如何在a标记上检索宽度设置(例如在REL属性中),并将其传递给jQuery fancybox函数,以便指定其宽度?以下是我(相当标准)的Fancybox声明: <script type="text/javascript"> $(document).ready(function () { //TODO - pass width/height value from link somehow $("a.popup")

如何在a标记上检索宽度设置(例如在REL属性中),并将其传递给jQuery fancybox函数,以便指定其宽度?以下是我(相当标准)的Fancybox声明:

     <script type="text/javascript">
        $(document).ready(function () {
            //TODO - pass width/height value from link somehow
            $("a.popup").fancybox({
                'autoScale': false,
                'height': 500,
                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                'type': 'iframe'
            });
        });
    </script>

$(文档).ready(函数(){
//TODO-从链接传递宽度/高度值
$(“a.popup”).fancybox({
“自动缩放”:false,
‘高度’:500,
“transitionIn”:“弹性”,
“transitionOut”:“弹性”,
“type”:“iframe”
});
});

您真的不应该为此重载
rel
属性,这不是它的用途

但是,代码可能看起来像

$(document).ready(function() {
    $("a.popup").each(function() {
        var width = $(this).attr('rel');

        $(this).fancybox({
            'autoScale': false,
            'width': width,
            'height': 500,
            'transitionIn': 'elastic',
            'transitionOut': 'elastic',
            'type': 'iframe'
        });
    });
});