Magnific Popu获取数据属性并将其放入变量

时间:2016-07-05 14:52:12

标签: javascript jquery magnific-popup

需要帮助获取数据属性并将其放入要在标记中使用的变量中。该属性为“data-mydesc”

非常感谢任何帮助。

HTML

<ul class="thumbnails">
                     <li class="image-additional"><a class="thumbnail" href="bigpic1.png" title="pic1 title" data-mydesc="this is a description1"> <img id="png1" 

src="pic1.png"></a>
                     </li>
                     <li class="image-additional"><a class="thumbnail" href="bigpic2.png" title="pic2 title" data-mydesc="this is a description2"> <img id="png1" 

src="pic2.png"></a>
                     </li>
                     <li class="image-additional"><a class="thumbnail" href="bigpic3.png" title="pic3 title" data-mydesc="this is a description3"> <img id="png1" 

src="pic3.png"></a>
                     </li>
</ul>

的javascript

                $('.thumbnails').magnificPopup({
                    type:'image',
                    delegate: '.image-additional a:visible',
                    image: {
                markup: '<div class="mfp-figure">'+
                        '<div class="mfp-close"></div>'+
                        '<div class="mfp-img"></div>'+ 
                        '<div class="mfp-title"></div>'+
                        '<div class="data-mydesc"></div>'+ 
                    '<div class="mfp-bottom-bar">'+
                        '<div class="mfp-counter"></div>'+
                        '</div>'+
                            '</div>', 
                 cursor: 'mfp-zoom-out-cur',
                  tError: '<a href="%url%">The image</a> could not be loaded.'
                  },
                  preloader: true,
                    gallery: {
                        enabled:true
                    }

                });

0 个答案:

没有答案