'unable to use the link that was appended

I am creating a website, that is just like a blog. I am able to show all the posts from the database but unable to show individual post because I cannot select the link that I appended.

$.ajax({       
url: '/get/all',       
contentType: 'application/json',       
success: function(response){        
 response.data.forEach(function(d){           
 var title = d.title;           
 var  content = d.recipie;            
 var author = d.author;            
 var idrecipie = d.idrecipie;
 $('#contentdiv').html("");         
 $("#maindiv").append('<h1> <a id="link" href="/get/'+idrecipie+'">'+title+'</a></h1>');         
});      
 }     
}); 
});```




Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source