I have a simple js script which gets backgrounds of the following elements:
<ul class="vk_image_grid">
<li style="background-image: url(https://name.com/image1.jpg)" class="block">
</li>
<li style="background-image: url(https://name.com/image2.jpg)" class="block">
</li>
<li style="background-image: url(https://name.com/image3.jpg)" class="block">
</li>
</ul>
<script>
$("ul li").on( "click", function() {
var bg = $(this).css('background-image');
alert(bg);
</script>
It works perfectly with the first two li
which are generated by php. But it doesn't show the background of the third li
which is generateed by another jQuery script. How can I fix the issue?