Jquery:如果最后一个滑动div

时间:2010-08-27 20:01:09

标签: php javascript jquery

我有这个朋友请求页面,我想要我的div

echo "<div style=' font-weight: bold; background: #283b43; border-bottom: 1px dashed #719dab;'>";
echo "<img src='images/NewFriend_small.png' style='float: left; margin-left: 25px; margin-right: 10px;'>";
echo "Friend requests";
echo "</div>";

如果这是用户拥有的最后一个朋友请求,也会消失。 现在它不会这样做,只会向上滑动实际请求(用户名,图片等)

我该如何检查它是否是最后一位朋友请求?

现在我的代码就像这样

    $friendsWaiting = mysql_query("SELECT * FROM users_friends where uID = '$v[id]' AND type = 'friend' AND accepted = '0'");
while($showW = mysql_fetch_array($friendsWaiting)){
echo "id: $showU[bID]";
}

JS接受/拒绝朋友的时候:

function MeYouFriendNB(confirm){
 var c = confirm ? 'confirm' : 'ignore';
var fID = $('#fID').val();

    $.ajax({ 
       type: "POST",
       url: "misc/AddFriend.php",
    data: {
    mode: 'ajax',
        friend: c,
    uID : $('#uID').val(),
    fID : $('#fID').val(),
        bID : $('#bID').val()
    },
       success: function(msg){
$('#friend'+fID).slideUp('slow');
$('#Friendlist').prepend(msg);
 $('#theNewFriend').slideDown('slow');
        }
     });
}

1 个答案:

答案 0 :(得分:5)

在jQuery中使用:last选择器

http://api.jquery.com/last-selector/

$('div.friend:last').slideUp();

那是你在找什么?