Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为jquery上的每个注释获取特定的动态输入隐藏值_Jquery_Ajax_Codeigniter - Fatal编程技术网

如何为jquery上的每个注释获取特定的动态输入隐藏值

如何为jquery上的每个注释获取特定的动态输入隐藏值,jquery,ajax,codeigniter,Jquery,Ajax,Codeigniter,我正在尝试按注释id删除注释,但只能获取第一条注释的值 <?php foreach($comment as $comments): ?> <div id="commentsection"> <div class="note"> <h5><?= $comments->c_content; ?></h5> </div>

我正在尝试按注释id删除注释,但只能获取第一条注释的值

<?php foreach($comment as $comments): ?>

    <div id="commentsection">
            <div class="note">
                <h5><?= $comments->c_content; ?></h5>
            </div>
            <input 
                type="hidden" 
                class="form-control" 
                id="commentid" 
                name="commentid" 
                value="<?= $comments->id; ?>">  

            <h5><i class="fa fa-user text-success"></i> 
            <?= $comments->username; ?> | <?= $comments->c_datetime; ?> 
            <?php echo ($username == $comments->username ? '
              | <a href="" id="delete-comment">
            <i class="fa fa-trash-o"></i> Delete</a>' : '' ) ?></h5>                                        
        </div>

<?php endforeach; ?>

试试这个

$('#delete-comment').click(function(){
   var commentid= $(this).parent().siblings().find('input[name="commentid"]').val();
});
您选择的注释id将存储在
commmentid