带有php生成的html的jquery不起作用


jquery with php generarated html not working

当我点击editlist class元素时,我下面的代码不起作用了。我该如何让它再次出现,比如点击切换editLish class元素。下面的任何更改都将非常感激,因为内容是动态生成的。

<script type="text/javascript">
    $(document).ready(function(){
        alert("clicked");
        $('.editList').on('click',function(){
        alert('clicked');
                    $(this).hide();
        });
    });
</script>
<? $this->_renderView(false, '_submenu')?>
<?php $cand_data=$this->read_xml();
    ?>
<div class="module" style="width:1050px">
    <div class="module_content">
        <?php foreach($cand_data as $key=>$data_node){ $i=0; ?>
        <table class="editList" style="">
            <tr>
                <th>Candidate Data</th>
            </tr>
            <?php foreach($data_node as $label=>$val) {   if($i<16){?>
            <tr>
                <td><?= $label?></td>
                <td><?= $val?></td>
            </tr>
            <?php $i++;}}?>
        </table>
        <?php  }?>    
    </div>
</div>

检查选择器的拼写-您已经将点击处理程序绑定到editlist,并且您的表类是editList

css类名区分大小写。您需要用大写的L$('.editlist')更改为$('.editList')

您的表类是"editList",但jquery选择器是".editList"(请注意L上的大小写不同)。Cs名称区分大小写。

使用$('.editList').click(...将工作