How do I close a dialog using jQuery?

前端 未结 5 1038
攒了一身酷
攒了一身酷 2021-02-02 11:09

I am using the code below to create a jQuery UI Dialog widget dynamically:

 $(function () {
        var Selector = $(\"a:contains(\'sometext\')\");
        $(Sel         


        
5条回答
  •  -上瘾入骨i
    2021-02-02 11:37

    A few points to think about:

    1. OnDialogClose you should detach #MenuDialog from DOM to avoid multiple objects with same ID or you can check whether div#MenuDialog exists before adding one.

    2. var Selector = $("a:contains('sometext')"); is a pointless line unless you re-use it else where.

    3. You use $('#MenuDialog') multiple times. It would be better to assign it to a variable instead of querying var Selector = $('#MenuDialog'); all over again .

提交回复
热议问题