为列表中的单个项目打开一个弹出窗口

Open a pop up for a single item in the list

本文关键字:一个 窗口 列表 单个 项目      更新时间:2023-09-26

我有项目列表。但是我正在展示一个示例代码。

我有以下HTML代码

<div id="starpline_timestamp_refer" title="Refer your friends" style="margin-left:10px;"><a class="refer_freinds" id="39342" href="javascript:void(0);">Refer your friends</a></div>
<div class='strapline_share_buttons' style='display:none;'>".elgg_view("addthis/extend", $vars)."</div>

这是重复十次,但我有不同的id为所有按钮,如id="39342"因此,当我点击refer your friends按钮时,strapline_share_buttons将为所有项目打开,因此我需要显示一个项目。

我jQuery:

$("a.refer_freinds").click(function(){
        var item_id =  $(this).attr("id"); 
        //$( ".strapline_share_buttons").toggle();
        $(this).$( ".strapline_share_buttons").toggle();
        });
        $(".strapline_share_buttons").popup("open", {
            "transition": "pop"
        });

那么该怎么做呢?

如果我正确理解问题和html布局,这段代码必须工作。

$("a.refer_freinds").click(function () {
    var item_id = $(this).attr("id");
    //go to parent and next element in DOM and show that
    //<div class='strapline_share_buttons' style='display:none;'>".elgg_view("addthis/extend", $vars)."</div>
    $(this).parent().next().show()
        .popup("open", {
        "transition": "pop"
    });
});
http://jsfiddle.net/9H9jq/2/