🤯 50% Off! 700+ courses, assessments, and books

jQuery Find and Remove Duplicated Element IDs

Sam Deering
Share

This example could be used to fix a featured article for your blogs so that not more than one article is featured on the homepage.

// featured article fix
var myFeatured = $('div.featured').attr('id');
var theHidden;
$('div.article').each(function(){
	theHidden = $(this).attr('id');
	if(theHidden == myFeatured){ 
		$('div#'+theHidden).hide();	
	}
});