[英]How can I use Tumblr elements with Javascript?
How can I use Tumblr elements such as {Permalink} with Javascript? 如何在Javascript中使用诸如{Permalink}之类的Tumblr元素?
Specifically to add a link to certain elements. 专门为某些元素添加链接。
My javascript: 我的JavaScript:
<script type="text/javascript">
$('.takemethere').each(function() {
var link = $(this).html();
$(this).contents().wrap('<a href="{Permalink}"></a>');
});
</script>
The HTML: HTML:
{block:Photo}
<div class="takemethere"><img src="{PhotoURL-500}" width="50px" height="50px" alt="{PhotoAlt}"/></div>
{block:caption}{Caption}{/block:Caption}
{/Block:Photo}
The {Permalink} element doesn't work as a link. {Permalink}元素不能用作链接。 It just refreshes the page when I click on the content that I have wrapped this link around.
当我单击包装此链接的内容时,它只会刷新页面。
You don't need javascript
, use the {Permalink}
theme operator directly in your theme: 您不需要
javascript
,直接在主题中使用{Permalink}
主题运算符:
{block:Photo}
<a href="{Permalink}">
<img src="{PhotoURL-500}" width="50px" height="50px" alt="{PhotoAlt}"/>
</a>
{block:caption}{Caption}{/block:Caption}
{/Block:Photo}
Reference: https://www.tumblr.com/docs/en/custom_themes#posts 参考: https : //www.tumblr.com/docs/en/custom_themes#posts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.