0

我不知道为什么这不起作用?我一直在使用点击,实时,它只是有效但不在这里......知道为什么吗?

什么在 p.tableItem.live 中不起作用

渲染的行看起来像这样

<tr>
    <td>
<p id="spEmailAddress_2_0" class="tableItem" alt="EmailAddress">charlie.nguyen@exacttarget.com</p></td><td><p id="spUserID_2_1"  class="tableItem" alt="Number">10442135</p></td><td><p id="spSubscriberKey_2_2" class="tableItem" alt="Text">charlie.nguyen@exacttarget.com</p>
    </td>
</tr>

这是未运行的脚本

<script type="text/javascript">

    $(document).ready(function() {

        $.post(wsUrl, { Method: "GetDEs"}).done(function(data){
            data = CreateObjectFromOutput(data);
            $("#DEContainer").html(BuildDEDDL(data));

            $("#ddlDE").change(function(){
                $.post(wsUrl, { Method: "GetFieldsAndRows", Input: JSON.stringify({ DEName: $(this).val()})}).done(function(data){
                    data = CreateObjectFromOutput(data);
                    $("#FieldContainer").html(BuildFiledTable(data));
                    $(".Date").datepicker();
                });
            });
        });

        $("p.tableItem").live("click", function(event){
            alert($(this).text());
        });

    });

</script>
</head>
<body>
    <div id="Wrapper">
        <div id="DEContainer"></div>
        <div id="FieldContainer"></div>
    </div>
</body>
</html>
4

2 回答 2

0

为什么不这样?

$("p.tableItem").click(function(){
   alert($(this).text());
});

或者

 $("p.tableItem").bind('click', function() {
    alert($(this).text());
});
于 2013-02-25T23:53:22.670 回答
0

表格行必须在table元素中,而不是在div元素中。将其更改为表格:

<table id="FieldContainer"></table>
于 2013-02-25T23:55:11.713 回答