Jquery - Display Alt attribute below each slide image

Asked

Viewed 255 times

1

So I need help with a code that I’m trying to develop. The site is all in Wordpress, and has a plugin called Master Slider. I need to develop a script that takes the Alt attribute of the images and displays below each image, and that this attribute changes according to the photo, obviously.

JQUERY CODE I HAVE:

    $( ".master-slider" ).append( "<p class='textoProduto'></p>" );
    $('.master-slider').each(function(){
    $(this).find('.textoProduto').html($(this).find('img').attr('alt')); 
    });

HTML OF THE PLUGIN:

    <!-- MasterSlider -->
    <div id="P_MS5a69ac9d1f2cf" class="master-slider-parent msl ms-parent-id-1" style="max-width:800px;"  >
        <!-- MasterSlider Main -->
        <div id="MS5a69ac9d1f2cf" class="master-slider ms-skin-default" >                    
        <div  class="ms-slide" data-delay="3" data-fill-mode="fill"  >
           <img src="http://www.sulpeneiras.com.br/wp-content/plugins/master-slider/public/assets/css/blank.gif" alt="contour-screen" title="" data-src="http://www.sulpeneiras.com.br/wp-content/uploads/2018/01/contour-screen-2-800x480.jpg" />
           <img class="ms-thumb" src="http://www.sulpeneiras.com.br/wp-content/uploads/2018/01/contour-screen-2-140x80.jpg" alt="contour-screen" />
<div class="ms-thumb" ><div class="ms-tab-context"><div class=&quot;ms-tab-context&quot;></div></div>
        </div>
        </div>
        <div  class="ms-slide" data-delay="3" data-fill-mode="fill"  >
            <img src="http://www.sulpeneiras.com.br/wp-content/plugins/master-slider/public/assets/css/blank.gif" alt="PENEIRA-FABRICADO-EM-POLIETILENO" title="" data-src="http://www.sulpeneiras.com.br/wp-content/uploads/2017/11/PENEIRA-FABRICADO-EM-POLIETILENO-1-800x480.jpg" />
        <img class="ms-thumb" src="http://www.sulpeneiras.com.br/wp-content/uploads/2017/11/PENEIRA-FABRICADO-EM-POLIETILENO-1-140x80.jpg" alt="PENEIRA-FABRICADO-EM-POLIETILENO" />
        <div class="ms-thumb" ><div class="ms-tab-context"><div class=&quot;ms-tab-context&quot;></div></div>
       </div>               
    </div>
 </div>
<!-- END MasterSlider Main -->   
</div>
<!-- END MasterSlider -->

WHAT I WANT TO APPEAR IN ALL IMAGES O que quero que aconteça

But the problem is that so far I’ve only been able to show the alt of the first slide image, and it’s fixed for everyone, and what I want to do is, when I change the slide, change the text of the alt

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.