【发布时间】:2015-07-01 23:59:01
【问题描述】:
如何通过单击图像来显示我的 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>
【问题讨论】:
-
创建一个 jsfiddle,jsfiddle.net
-
你可以先把你所有的js代码放在document ready函数里面。
标签: javascript jquery