单击显示模态jquery

display modal jquery by click

本文关键字:jquery 模态 显示 单击      更新时间:2023-09-26

如何通过单击图像来显示jQuery模态?看看这个:

实际上,我正试图在模态框中显示JQplot图表。点击图像后,方框应显示

在同一页上。。

<div id="dialog" title="Basic dialog">
 <div id="chart1" style= "width:40%;height:200px"> </div>
</div>
<img id="imgg" src = "stats_matching/gprier.gif" alt = "perso">

  <script>
  $(document).ready(function(){
    $.jqplot.config.enablePlugins = true;
    var s1 = [2, 6, 7, 10];
    var ticks = ['a', 'b', 'c', 'd'];
    plot1 = $.jqplot('chart1', [s1], {
        // Only animate if we're not using excanvas (not in IE 7 or IE 8)..
        animate: !$.jqplot.use_excanvas,
        seriesDefaults:{
            renderer:$.jqplot.BarRenderer,
            pointLabels: { show: true }
        },
        axes: {
            xaxis: {
                renderer: $.jqplot.CategoryAxisRenderer,
                ticks: ticks
            }
        },
        highlighter: { show: false }
    });
});     
        $("#dialog").hide();
        $('#imgg').click(
            function() {
                $(this).data('clicked',true);
            }
        );
        if($('#imgg').data('clicked')) {
                console.log('refefez');
                $("#dialog").show().dialog();
        }

  </script>

您需要一个函数来监听数据属性。

  ` $(document).on('data-attribute-changed', function() {
       if($('#imgg').data('clicked')) {              
            $("#dialog").show().dialog();
        }         
  });`

谢谢,查尔斯。