addID in jQuery?

后端 未结 4 644
日久生厌
日久生厌 2020-12-01 01:02

Is there any method available to add IDs like there is for adding a class - addClass()?

4条回答
  •  抹茶落季
    2020-12-01 01:29

    Like this :

    var id = $('div.foo').attr('id');
    $('div.foo').attr('id', id + ' id_adding');
    
    1. get actual ID
    2. put actuel ID and add the new one

提交回复
热议问题