jquery 单击对话框中的任意位置

jquery fire a click anywhere within a dialog box

我有一个对话框 Window,有一个 2 x 2 table。我希望能够单击任何单元格,而不是单击按钮,它 returns 警告框中的 value/text。但是我不确定我会把下面的 alert($(event.target).text()); 放在哪里?

$("#dialog-message").dialog({
    modal: true,
    draggable: false,
    resizable: false,
    position: ['center', 'top'],
    show: 'blind',
    hide: 'blind',
    width: 400,
    dialogClass: 'ui-dialog-osx',
    buttons: {
        "I've read and understand this": function() {
            $(this).dialog("close");
        }
    }
});

这里是代码Fiddle

如果需要单元格文本,请将点击事件绑定到 th,td(根据您的标记)。

$("#dialog-message th,td").click(function(event){
    alert($(event.target).text());  //$(this).text() would work too.
});

Updated Fiddle