【问题标题】:Photo tagging - Hovering on name to show the tagged box照片标记 - 悬停在名称上以显示标记的框
【发布时间】:2016-03-22 08:10:30
【问题描述】:

我正在尝试这样做,以便当列表中的标签名称悬停时,它应该在它被标记的位置显示一个框(如 Facebook)。

这是我的代码:

Viewtag.php

<?php
$sql = "SELECT * FROM image_tag ORDER BY `pic_id`";
$qry = mysql_query($sql);
$rs = mysql_fetch_array($qry);

if ($rs){
  do{
    echo '<li rel="'.$rs['pic_id'].'"><label>'.$rs['name'].'</label></li>';
  }while($rs = mysql_fetch_array($qry));
}
?>

索引.php

.tagview
    {
      border:solid 3px #fff;
      width:100px;
      height:100px;
      position:absolute;
      display:none;
}

$('#taglist li').on('mouseover mouseout',function(event){
      pic_id = $(this).attr("rel");
      if (event.type == "mouseover"){
        $('#view_' + pic_id).show();
      }
      if (event.type == "mouseout"){
        $('#view_' + pic_id).hide();
      }
});

    viewlist();

    function viewlist()
    {
     $.post('viewtag.php', function(data){
            $('#taglist ol').html(data);
          });

}

<?php
    $query = mysql_query("SELECT * FROM image_tag");
    $run = mysql_fetch_array($query);
    if($run){
        do{
?>
            <div class="tagview" style = "top:<?php echo $top; ?>px; left:<?php echo $left; ?>px;" id="view_<?php echo $number; ?>"></div>
<?php
        }while($run = mysql_fetch_array($query));
    }
?>

<div id="taglist"> 
    <span class="tagtitle">List of Tags</span> 
        <ol> 
        </ol>
</div>

这很令人困惑,所以我发布了到目前为止我尝试过的内容。

【问题讨论】:

    标签: php jquery html mysql ajax


    【解决方案1】:

    首先 pic_id 是你的变量,那么为什么你在没有var 的情况下这样声明

    pic_id = $(this).attr("rel");
    

    对此var pic_id = $(this).attr("rel");进行了更改

    【讨论】:

      【解决方案2】:

      http://www.wellbro.com/view_tutorial?t_cat=3&t_i=3

      这里是“JQuery, PHP - 照片标记系统”教程的 URL

      【讨论】:

      • 大声笑,我在问这个问题后就在 YouTube 上找到了你。 :D
      猜你喜欢
      • 2021-12-13
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多