<h2 class="altText"><img src="https://try-m.co.jp/wp-content/uploads/2016/09/150x150.png" alt="ALTテキスト"></h2>
.sp {
  display: none;
}
@media screen and (max-width: 768px) {
  .pc {
    display: none;
  }
  .sp {
    display: block;
  }
}
$(function(){

  $('.altText').each(function(){

    alt = $(this).find('img').addClass('pc').attr('alt');
    $(this).prepend('<span class="sp">' + alt + '</span>');

  }); 

});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js