I need to add an attribute to specific images by using JS or jQuery, but I can't figure it out.
I'm using WordPress and the images that I want to add the attribute are inside a slider, so I cannot add any class to those images.
I tried to add the attribute that I want by using the container class to find images, but it didn't work.
$('.dce-img > img').attr('rlskip', '1');
This how I want it to be:
<div class="dce-item">
<figure data-image-ratio="0.5" class="dce-img dce-fit-img">
<img src="../img/F4D13DA3-5351-4F69-8C33-0A1EF3BFDF67.webp" alt="Demo_ts_2" rlskip="1">
</figure>
</div>
Can you help me to find a solution please? I have to add the rlskip attribute to the images of the slider here.
The problem is that $ is not defined. Change $ to jQuery like below:
jQuery('.dce-img > img').attr('rlskip', '1');