Qtip不加载REL URL

时间:2011-02-01 13:04:14

标签: jquery ajax url qtip rel

我正在使用Jquery 1.4.4和Qtip,我正在尝试为每个单独的列表项加载图像,所以我使用Content:URL:.attr(rel),但它不会加载REL的URL < / p>

<script type="text/javascript">
// Create the tooltips only on document load
$(document).ready(function() {
$('ul.list-one li a[href]').each(function(){
  $(this).qtip({
     Content: { url: $(this).attr('rel') },
     position: {
     corner: {
        target: 'topMiddle',
        tooltip: 'bottomMiddle'
                }
                },
     style: {
       tip: 'bottomMiddle',
       border: { width: 2, radius: 2, color: '#A9D041' },
     background: '#fff',
     padding:0,
     width: 175,
     height:100
       }  

   });
});
});
</script>




 <ul class="list-one">
 <li class="header">Project Management</li>
 <li><a href="#">BGC Bremerholm</a></li>
 <li><a href="#">Medtronic</a></li>
 <li><a href="#">Straumur - Burdaras Bank</a></li>
 <li><a href="#">Straumur Reykjavik</a></li>
 <li><a href="#">Straumur Stockholm</a></li>
 <li><a  rel="/test/test.html" href="#">T. Rowe Price</a></li>

 </ul> 

3 个答案:

答案 0 :(得分:1)

您可以简单地使用jquery中的每一个来获取所有元素并将qtip应用于它们。您可以通过这种方式轻松操作它们。

$('.qtip').each(function(){
    $(this).qtip({
      content: { url: $(this).attr('rel'), method: 'get' },

      style: {
         padding: '7px 13px',
         width: {
            max: 510,
            min: 0
         },
         tip: true
      }
    });
  });

答案 1 :(得分:0)

Content应为小写c

content: { url: $(this).attr('rel') },

答案 2 :(得分:0)

goetz,document.ready()函数意味着你不需要把它放在页面的底部,它等待页面在开始之前加载。

我将它用于最近的一个项目,它的工作正常:)

$('.test').each(function(){
        $(this).qtip({
          content: { text: '<img src="' + $(this).attr('href') + '" />' },
          show: { delay: 0 },
        });
      });