set id of element jquery code example
Example 1: change id in jquery
$('#writ_issued_c_trigger').attr('id','oepl_writ_issued')
Example 2: store id of an element jquery
$(". only_this_class"). click(function() { var clickedId= $(this). attr("id"); alert(clickedId); });
Example 3: add id in jquery
TO add dynamically:
let $id=0;
$('ul li').each(()=>{
$(this).attr('id','id'+$id)
$i=$i+1
})
using js
const s=document.getElementsByTagName('li');
len=s.length;
console.log(len)
for(let i=0;i<len;i++){
s[i].id="id"+i;
}