最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Display the data in <div> into popup using JQuery - Stack Overflow

programmeradmin4浏览0评论
<script type="text/javascript">

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

        $("#btn_click").click(function() {
            $("#popup_div").dialog("open");
            //$("#popup_div").toggle("100", $("#popup_div").dialog("close"));
        });
    });

</script>

I wrote a function which will display the data in popup and immediately the popup will close. I need that popup stays sometime after clicking close button it will close.

<script type="text/javascript">

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

        $("#btn_click").click(function() {
            $("#popup_div").dialog("open");
            //$("#popup_div").toggle("100", $("#popup_div").dialog("close"));
        });
    });

</script>

I wrote a function which will display the data in popup and immediately the popup will close. I need that popup stays sometime after clicking close button it will close.

Share Improve this question edited Aug 18, 2014 at 5:44 Mathias 5,6702 gold badges33 silver badges47 bronze badges asked Aug 18, 2014 at 5:24 user3887236user3887236 1011 gold badge1 silver badge5 bronze badges 1
  • can you make fiddle of the same ??? – ankur140290 Commented Aug 18, 2014 at 6:06
Add a ment  | 

2 Answers 2

Reset to default 3

Try this,

$("#btn_click").click(function () {
    $("#popup_div").dialog("open");
});
// code to close the dialog, let btnClose is the Id of button in popup_div
$("#popup_div").on('click','#btnClose',function(){
     $("#popup_div").dialog("close");
});

Demo

If you want the dialog to delay before closing then set a timeout:

   $("#popup_div").on('click', '#btnClose', function () {
        setTimeout(function() {
            $("#popup_div").dialog("close");
        }, 1000);
    });

JSFiddle example:

http://jsfiddle/606pgg4o/1/

发布评论

评论列表(0)

  1. 暂无评论