2011-02-28 108 views
1

我正在使用JQuery Bubble Popup库,试图在innerHtml变量中显示隐藏的div。现在,我有这样的:JQuery Bubble Popup:innerhtml隐藏div div

<div class="button"> Show stuff </div> 
<div class="information"> foo </div> 

<div class="button"> Show stuff </div> 
<div class="information"> bar </div> 

<script> 
$(document).ready(function(){ 
     $('.information').hide(); 
     $('.button').CreateBubblePopup({ 
             position: 'bottom', 
             align: 'center', 
             width: '300', 
             innerHtml: $(this).next(".information").html(), 
             innerHtmlStyle: { color:'#000', 'text-align':'left', 'font-size':'110%' }, 
             themeName: 'grey', 
             themePath: '/static/images/jquerybubblepopup-theme', 
             selectable: true, 
             }); 
     }); 


</script> 

的事情是,它不工作如我所料,问题出在线路

innerHtml: $(this).next(".information").html(), 

因为如果我把这个工作原理:

innerHtml: 'testing jquery bubblepopup', 
+0

你能解释一下这个问题到底是什么吗? – 2011-02-28 17:53:04

回答

1

这一行的问题:

innerHtml: $(this).next(".information").html(), 

this不是指你认为它指的是什么。我想认为你希望它指向当前按钮受到影响,但它不是 - 它是this值在“就绪”处理程序上下文中生效。

你能做什么(除了几件事情)是使用“每()”函数:

$('.button').each(function() { 
    $(this).CreateBubblePopup({ 
    position: 'bottom', 
    align: 'center', 
    width: '300', 
    innerHtml: $(this).next(".information").html(), 
    innerHtmlStyle: { color:'#000', 'text-align':'left', 'font-size':'110%' }, 
    themeName: 'grey', 
    themePath: '/static/images/jquerybubblepopup-theme', 
    selectable: true 
    }); 
}); 

而且你在气泡弹出参数对象,结束了流浪逗号这会从IE获得一个错误。