Currently, I am working on a webpage that will trigger an ajax call upon loading. The response data in JSON format will be processed and the elements will then be added to the DOM as shown below:
$.ajax({
type: 'POST',
url: "http://mysite.dev:32769/getallnews",
success: function(data){
$container.append(item)
.isotope( 'appended', item );
}
});
I would like to mention that I am incorporating Metafizzy's Isotope library. More information can be found here.
For demonstration purposes, there is a
<div class="article-block"></div>
present in the DOM initially, with another one appended after the ajax call completes.
The following jQuery code only works for detecting hover on the first div element and not the second:
$(".article-block").hover(function(){
//hover on
$(".article-block div").fadeIn();
},function(){
//hover off
$(".article-block div").fadeOut();
});
After spending time debugging, I observed that typing $('.article-block');
in the console displays both elements correctly. However, when hovering over the first one, the fade effect occurs, while it does not work for the second one.
Any suggestions or ideas on how to fix this issue?