Changing an element’s ID with jQuery September 26, 2022 by Tarik Your syntax is incorrect, you should pass the value as the second parameter: jQuery(this).prev("li").attr("id","newId");