-1

我有这个div标签,其中包含一个 Google 可视化图表。onclick我想要的是通过图表( )在弹出框中弹出该图表div

我正在使用 jQuery。

4

2 回答 2

2

只需抓取单击的 div 的内容并将其复制到另一个 div,然后您可以正确定位。

$(".someChart").on("click", function() {
    // Fill popup with html
    $('.popupDiv').html($(this).html());
    // now show the popup and possibly position it correctly
    $('.popupDiv').show();
});
于 2013-06-13T11:59:18.630 回答
2

CSS

.model{
    display:none;
    position:absolute;
    z-index:1000;
    top:20%;
    left:20%;
    padding:10px;
    border:1px solid #000;
    width:auto;
    height:auto;

}

jQuery

$(".chartDiv").on("click", function () {
   var content = $(this).html();
    $('.model').show().html(content);


});

html

<div class="chartDiv">Chart 1</div>
<div class="chartDiv">Chart 2</div>
<div class="model"></div>

工作演示

于 2013-06-13T12:10:35.730 回答