如何在jQuery中更改attr()

如何在jQuery中更改attr(),jquery,html,Jquery,Html,这是我目前的格式 <div class="post-item" id="4126"> ...entry... </div> 让我知道如果我正确理解了你的问题,我想你想把attr从4126改为#post4126,因为id不能是纯数字。这是如何做到的: url: "more.php?lastid=" + $(".post-item:last").attr("id").split('_')[1]; var x = $(".post-item:last").attr("i

这是我目前的格式

<div class="post-item" id="4126">
  ...entry...
</div>

让我知道

如果我正确理解了你的问题,我想你想把attr从
4126
改为
#post4126
,因为id不能是纯数字。这是如何做到的:

url: "more.php?lastid=" + $(".post-item:last").attr("id").split('_')[1];
var x = $(".post-item:last").attr("id");
url: "more.php?lastid=" + 'post_' + x;

如果我正确理解了您的问题,我想您应该将attr从
4126
更改为
#post4126
,因为id不能是纯数字。这是如何做到的:

var x = $(".post-item:last").attr("id");
url: "more.php?lastid=" + 'post_' + x;