【问题标题】:how to display the same image in dialog box when it is clicked in a html page?在html页面中单击时如何在对话框中显示相同的图像?
【发布时间】:2017-09-14 15:46:52
【问题描述】:

当我使用按钮标签时,代码正在显示对话框,但在使用图像标签时,对话框没有出现。 有人可以帮忙吗?

 <img src='image.png' height='200px' widht='200px' id='1'>

<div id="dialog" title="An Image!" >
  <img id="image" src="hello.jpg"/>
</div>

jquery:

        $(document).ready(function() {
   $( "#dialog" ).dialog({ autoOpen: false });
$( "img" ).click(function() {
  $( "#dialog" ).dialog( "open" );
});
});

【问题讨论】:

  • 我不相信你想要达到的目标可以那样做。我建议您实现一个行为类似于对话框的自定义模式。或者使用现成的插件。
  • @N.Ivanov 非常感谢,能够使用自定义模型做到这一点。

标签: javascript jquery html image


【解决方案1】:
<img src='image.png' height='200px' widht='200px' id='1'>

<div id="dialog" title="An Image!" >
  <img id="image" src="image.png"/>
</div>


$(document).ready(function() {
  $( "#dialog" ).dialog({ autoOpen: false });
  $( "img" ).click(function() {
  $( "#dialog" ).dialog( "open" );
  });
});

【讨论】:

    猜你喜欢
    • 2012-07-11
    • 1970-01-01
    • 2017-07-23
    • 1970-01-01
    • 1970-01-01
    • 2011-11-27
    • 2011-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多