我正在尝试在 jquery 中选择引导程序“well”的最后一个 ID。
这有效,但不适用于加载 ajax 的井,请参阅下面的尝试,有什么建议吗?
var newest = $('.well:last').attr('id');
setInterval(function() {
console.log(newest);
    $.ajax({
    type: 'POST',
    url: 'ajax/getNew.php',
    data: "id="+newest+"&session=<?php echo $sesh; ?>",
    cache: false,
    success: function(html) {
        $("#convo").append(html);
        newest = $(html).filter('.well:last').attr('id');
    }
    });
}, 3000);
通过成功的 ajax 结果添加新井后,var latest 未定义。