Result
classはaddClassという専用関数がありますけどIDは無いのでattrを使います。
jQuery
$('div').attr('id', 'new');
css
#new{
height:250px;
width:250px;
background:#eee;
margin:25px;
}
html
<div class="foo">add ID</div>
classはaddClassという専用関数がありますけどIDは無いのでattrを使います。
$('div').attr('id', 'new');
#new{
height:250px;
width:250px;
background:#eee;
margin:25px;
}
<div class="foo">add ID</div>