Abbasi
Abbasi

Reputation: 125

jquery with php generarated html not working

My code below is not working when I click on to the editlist class element disappears how can I make it appear again such as toggling the editLish class element with clicks any change in the below will be much appreciated as the content is generated on the fly

<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>

Upvotes: 0

Views: 60

Answers (3)

Lepidosteus
Lepidosteus

Reputation: 12037

Your table class is "editList" but your jquery selector is ".editlist" (note the differing case on the L). Css names are case sensitive.

Using $('.editList').click(... will work

Upvotes: 0

DiverseAndRemote.com
DiverseAndRemote.com

Reputation: 19888

css class names are case sensitive. you need to change $('.editlist') to $('.editList') with a capital L

Upvotes: 1

freejosh
freejosh

Reputation: 11383

Check your selector spelling - you've bound the click handler to editlist and your table class is editList.

Upvotes: 1

Related Questions