i want to change the id of an element in jquery i.e
$('.aiButton').click(function(){
$('.aiButton').id('saveold');
<a class="aiButton" id="savenew" href="login.php"><span>Save</span></a></li>
you see i want to chnage the id from savenew to saveold
is this how you do it, i think this is worng thanks!!
i want to change the id of an element in jquery i.e
$('.aiButton').click(function(){
$('.aiButton').id('saveold');
<a class="aiButton" id="savenew" href="login.php"><span>Save</span></a></li>
you see i want to chnage the id from savenew to saveold
is this how you do it, i think this is worng thanks!!
-
There isn't an
id()
function. – BoltClock Commented Dec 29, 2010 at 19:12 -
2
He mentioned
i.e.
not literally. – MacMac Commented Dec 29, 2010 at 19:16
2 Answers
Reset to default 7To set the ID, you need $('.aiButton').attr('id', 'saveold');
, or more efficiently in this case this.id = 'saveold'
.
I do this:
$('.aiButton').click(function()
{
// $(this).removeAttr('id');
$(this).attr('id', 'id-name-goes-here');
});