嗨,伙计们,我在博客上动态更改alt标签时遇到了麻烦。
我尝试了以下脚本,它在我的旧博客上作为测试示例,但我将此脚本添加到使用最新窗口小部件的博客中。
<script>
$("img").each(function() {
$(this).attr('alt', '<data:title/>');
});
</script>有什么想法吗?
发布于 2015-05-16 14:18:58
它应该是<data:post.title/>
<script>
$("img").each(function() {
$(this).attr('alt', '<data:post.title/>');
});
</script>发布于 2017-10-14 16:59:11
<script>
$("img").each(function() {
$(this).attr('alt', '<data:post.title/>');
});
</script>博客的标题嵌入在JQuery代码中
data:blog.title
<data:post.title/>
<meta expr:content='data:blog.title' property='og:site_name'/>发布于 2019-01-24 17:46:54
代码会自动将标题插入到图像中
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
$('img').each(function(){
var $img = $(this);
var filename = $img.attr('src')
$img.attr('alt', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
});
});
//]]>
</script>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
$('img').each(function(){
var $img = $(this);
var filename = $img.attr('src')
$img.attr('title', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
});
});
//]]>
</script>查看更多https://www.cuongbv.com/2018/12/code-inserts-alt-tag-automatically-in-blogger.html
https://stackoverflow.com/questions/16551600
复制相似问题