I have data from database that needs to be placed according to the cell index and row index as shown:
<script>
$('.myTable tr:eq( <?php echo $row; ?> )').find('td:eq(<?php echo $col; ?>)').text('<?php echo $data; ?>');
</script>
But how do I add link to the td? I've tried this:
<script>
$('.myTable tr:eq( <?php echo $row; ?> )').find('td:eq(<?php echo $col; ?>)').html('<?php echo "<a href='#' id='data'>" .$data. "</a>"; ?>');
</script>
and this:
<script>
$('.myTable tr:eq( <?php echo $row; ?> )').find('td:eq(<?php echo $col; ?>)').append('<?php echo "<a href='#' id='data'>" .$data. "</a>"; ?>');
</script>
But none is working. Am I doing it wrong?
答案 0 :(得分:0)
试试这个:
<script>
$('.myTable tr:eq( <?php echo $row; ?> )').find('td:eq(<?php echo $col; ?>)').html('<?php echo "<a href=\'#\' id=\'data\'>" .$data. "</a>"; ?>');
</script>
答案 1 :(得分:0)
试试这个:
<script>
var data = '<?php echo $data; ?>';
$('.myTable tr:eq( <?php echo $row; ?> )').find('td:eq(<?php echo $col; ?>)').html("<a href='#' id='data'>"+ data +"</a>");
</script>