Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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 唯一Div不在特定图标上滑动切换单击_Jquery_Html_Css - Fatal编程技术网

Jquery 唯一Div不在特定图标上滑动切换单击

Jquery 唯一Div不在特定图标上滑动切换单击,jquery,html,css,Jquery,Html,Css,以下是单击图标的html代码: <a href="javascript:void(0)" class="stat-item remark" id='id' rel='msg_id' title='Give your Remarks on it'> <i class="fa fa-comments-o icon"></i> </a> 我的项目包括显示几个div(使用php的fetcharrayloop函数从数据库中提取),其中包含不同的内容。但

以下是单击图标的html代码:

<a href="javascript:void(0)" class="stat-item remark" id='id' rel='msg_id' title='Give your Remarks on it'>
  <i class="fa fa-comments-o icon"></i>
</a>

我的项目包括显示几个div(使用php的
fetcharray
loop函数从数据库中提取),其中包含不同的内容。但是在我能看到的每个div中,div的post-footer类都是相同的,比如icon。我的问题是,当我单击图标时,我可以看到所有名为“post footer”的类都在滑动切换。如何使它们在每次单击图标时独立滑动切换(class=“stat item remark”)

使用
data-*
属性,将相关
post footer
data id
存储在链接中,如:

<a href="" class="stat-item remark" data-msg-id="<?php echo $omsg_id;?>" title='Give your Remarks on it'>
  <i class="fa fa-comments-o icon"></i>
</a>  

<div class="post-footer" id="post-footer-<?php echo $omsg_id;?>">
  <p>Loading the list</p>
</div>
希望这有帮助

$(文档).ready(函数(){
$(“.stat item.remark”)。在(“单击”,函数(e){
var post_footer_id=“#post footer-”+$(this.data('id');
$(post_footer_id).css({backgroundColor:'yellow'});
});
});

加载列表

加载列表

加载列表


如果链接和div相邻,请执行
next()


@PraveenKumar你到底在说什么?每个的rel值应该是多少?我不知道你为什么要用它?没有必要。。如果您想将
msg_id
存储在某个地方,最好将其存储在
data msg id
属性中。是的,我想为来自dbi的每个invidual帖子附加msg_id。我想精确地处理演示中显示的内容。不幸的是,它不起作用。但我相信您的解决方案将有效地将
rel
替换为
数据消息id
。。。尝试添加一个
警报(post\u footer\u id)
,以确保从链接中获得正确的
数据id
$(document).ready(function(){
  $(".stat-item.remark").on("click", function( e ) {
    $(".post-footer").slideToggle();
  });
});
<a href="" class="stat-item remark" data-msg-id="<?php echo $omsg_id;?>" title='Give your Remarks on it'>
  <i class="fa fa-comments-o icon"></i>
</a>  

<div class="post-footer" id="post-footer-<?php echo $omsg_id;?>">
  <p>Loading the list</p>
</div>
$(document).ready(function(){
  $(".stat-item.remark").on("click", function( e ) 
  {
      e.preventDefault();

      var post_footer_id = "#post-footer-"+$(this).data('msg-id');

      $(post_footer_id).slideToggle();
  });
});
<a href="javascript:void(0)" class="stat-item remark" id='<?php echo $omsg_id;?>'rel='<?php echo $msg_id;?>' title='Give your Remarks on it'>
  <i class="fa fa-comments-o icon"></i>
</a>  
<div class="post-footer" id="post-footer">
  <p>Loading the list</p>
</div>
$(document).ready(function(){
        $(".stat-item.remark").on("click", function(e) {
          $(this).next(".post-footer").slideToggle();
        });
});