addID in jQuery?

后端 未结 4 668
日久生厌
日久生厌 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:32

    do you mean a method?

    $('div.foo').attr('id', 'foo123');
    

    Just be careful that you don't set multiple elements to the same ID.

提交回复
热议问题