简体   繁体   中英

how to display alert message box with radio button in javascript

<html>    
  <body>
    <button id="dialog">Show Popup</button>
  </body>
  <script type="text/javascript">
      var popUpList = $('<div><input type="radio">A<br><input type="radio">B<br><input type="radio">C</div>');
      $("#dialog").click(function() {
        popUpList.dialog();
      });
    </script>
  </body>  
</html>

Possibly you are missing the imports of jQuery and ui

 $(function() { var popUpList = $('<div><input type="radio">A<br><input type="radio">B<br><input type="radio">C</div>'); $("#dialog").click(function() { popUpList.dialog(); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" /> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <button id="dialog">Show Popup</button> 

You have to capture the page load event to instantiate a jQuery UI object.

try this:

<script type="text/javascript">
    $(document).ready(function() {
     var popUpList = $('<div><input type="radio" name="a">A<br><input type="radio" name="a">B<br><input type="radio" name="a">C</div>');
        $("#dialog").click(function () {
            popUpList.dialog();
        });
    });
</script>

OR

<script type="text/javascript">
  $(function(){
    //  now we know that jQuery has been loaded and is ready.
  });
</script>

请试试 :

 popUpList.dialog("open");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM