1

我有这个代码

<?php
if(!empty($auction['Auc']['beginner'])){
?>   

<a href="#" id="trigger_beginner"><?= $html->image('badge/beginner_icon.png', array('width'=>"30", 'height'=>"30", 'border'=>"0", 'alt'=>"Beginner auction", 'title'=>"Beginner auc"))?></a>
<div class="tooltip">
    <label>Beginner</label>
    <label>For an explanation <a href="/pages/auct#beginner">please click here</a></label>
</div>
<script>
$(function() {
    $("#trigger_beginner").tooltip();
});
</script>

<?php
}
?>

问题是当我有两次拍卖类型相同的拍卖时,例如在这种情况下像初学者一样,那么工具提示仅适用于一次拍卖。我希望它在所有类似的拍卖中显示工具提示..

4

2 回答 2

1

更改您的代码以使用它:

<?php if(!empty($auction['Auc']['beginner'])){?>   
   <a href="#" class="trigger_beginner"><?= $html->image('badge/beginner_icon.png', array('width'=>"30", 'height'=>"30", 'border'=>"0", 'alt'=>"Beginner auction", 'title'=>"Beginner auc"))?></a>
   <div class="tooltip">
       <label>Beginner </label>
       <label>For an explanation <a href="/pages/auct#beginner">please click here</a></label>
   </div>
   <script>
       $(function() {
            $(".trigger_beginner").tooltip();
       });
   </script>
<?php } ?>

ID 必须是唯一的,因此您需要使用不同的 ID 或类。

于 2012-12-18T14:17:54.667 回答
1

元素的 ID 应该是唯一的。没有两个元素应该具有相同的 ID。您应该使用CSSclass 作为您的 jquery 选择器

$(function() {
    $(".yourCssClassName").tooltip();
});

假设你所有的拍卖品都有这个类yourCssClassName

于 2012-12-18T14:18:00.747 回答