1

我正在尝试基于 jQuery 中的 td 单击打开一个模式窗口。好像没有开火 我查看了我的代码,这一切似乎都是正确的。我可能做错了什么?

<script type="text/javascript">
  $(document).ready(function () { <? php
      for ($i = 1; $i <= 9; $i++) { ?> $("td#grid2_mon<?php echo $i ?>").click(function () {
              $("#search_dialogMon<?php echo $i ?>").dialog({
                  modal: true,
                  height: 400,
                  width: 400,
                  buttons: {
                      Close: function () {
                          $(this).dialog("close");
                      }
                  }
              });
          }); <? php
      } ?>
  }
</script>
<?php 
  for ($i=1 ; $i <=9 ; $i++) { ?>
    <div id="search_dialogMon<?php echo $i ?>" style="display:none"></div>
<?php } ?>

<table>
<tr id="grid2_mon">
    <td class="gridSide">Mon</td>
    <td class="box" id="grid2_mon1">&nbsp;</td>
    <td class="box" id="grid2_mon2">&nbsp;</td>
    <td class="box" id="grid2_mon3">&nbsp;</td>
    <td class="box" id="grid2_mon4">&nbsp;</td>
    <td class="box" id="grid2_mon5">&nbsp;</td>
    <td class="box" id="grid2_mon6">&nbsp;</td>
    <td class="box" id="grid2_mon7">&nbsp;</td>
    <td class="box" id="grid2_mon8">&nbsp;</td>
    <td class="box" id="grid2_mon9">&nbsp;</td>
  </tr>
</table>
4

1 回答 1

1
your coding is not done properly you have made many syntax errors please try this code this will help you    
<script src="jquery-1.9.1.js">    </script>`    `<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js">      </script>`
<script type="text/javascript">
$(document).ready(function () { 
    $("td ").click(function () {
    var id = $(this).attr('id');
    $("#search_dialogMon"+id).dialog({height: 400,width:500,modal: true,    
        buttons: [{text: "OK",click: function() {$( this ).dialog( "close" );}}]
    });
    }); 
});
</script>
<?php 
for ($i=1 ; $i <=9 ; $i++) { ?>
<div id="search_dialogMon<?php echo $i; ?>" style="display:none">testing no<?php echo $i;?> </div>
<?php } ?>
<table>
<tr id="">
<td class="gridSide">Mon</td>
<?php 
for ($i=1 ; $i <=9 ; $i++) 
{ 
?>
<td class="box" id="<?php echo $i; ?>">mon<?php echo $i; ?></td>
<?php
}
?>
</tr>
</table>
于 2013-02-20T19:18:39.207 回答