Why my Dialog box isn't working

2019-06-12 13:55发布

问题:

This is the code I am trying and not working, nothing comes up at all

<script type="text/javascript" src="jquery/jquery.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.min.js"></script>
<script type="text/javascript">
    function HandleIt()
    {
        var objA = $get('<%= chkBox.ClientID %>');

        if(objA.checked == false)
            $("#dialog").dialog();

            //alert("it works");
    }  
</script>
<div style="width: 800px;">
    <asp:ScriptManager ID="ScriptMan1" runat="server" />
    <div class="dialog">
        <div class="a">
        <asp:Label ID="lbla" runat="server" CssClass="text" />
    </div>
    <div class="b">
        <asp:Label ID="lblb" runat="server" CssClass="text" />
    </div>
</div>

Code I given down works when dialog when it is like this,

<div class="dialog"> Hahahahaha </div>

I want to use it as message box but its not working out.

回答1:

Because your selector is catches tag with id's and you need hit by class. Try to change your selector to this one: $(".dialog").dialog();



回答2:

See here are the jQuery selector. You will get the briefly knowledge on it....

and replace your following code

 $("#dialog").dialog();

With below code

 $(".dialog").dialog();

And ya please see the jquery selectors...