Skip to content

Instantly share code, notes, and snippets.

@alt-karate

alt-karate/common.js

Created Oct 20, 2020
Embed
What would you like to do?
//画像をテキストに置き換え
$(function(){
$(".sp_text").each(function(i){
var txt = $("img",this).attr("alt");
$(this).attr("data-label", txt);
});
})
<p class="sp_text"><img src="images/txt.png" alt="WebDesign Dackel" /></p>
/* スマホ時画像のalt属性をテキスト化 */
.sp_text:after {
content: attr(data-label);
}
.sp_text img {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.