You can use prepend () function for jquery. You just need to select the image element and then call the prepend function. See an example:
$('.target_image').prepend('<div class="f1_card"></div>');
This will be fine if you want to add an element, if you want to add before an element. But if you want to wrap a div element, you need to use the wrap () function.
$('.target_image').wrap('<div class="f1_card"></div>');
And, obviously, you need to put this code above in the function of a click or similar event that you want. see example:
$('.target_image').on('click', function(){ $(this).prepend('<div class="f1_card"></div>'); });
Here the div with class "f1_card" will be the parent class of your target_image element. Hope this helps you.
source share