我正在使用Tumblr作为我的CMS来建立一个小型投资组合,并且我需要在索引页面上有缩略图。最好的方法似乎是在正文中嵌入缩略图,以便通过它来拉取图像,然后通过将其与其他图像的唯一高度进行匹配,通过修改CSS来隐藏它在文章页面上的显示,即将其设置为`display:none'。 理论上看起来很棒,但目前并没有起作用。我错过了什么?父div类别是
.text
。<script type="text/javascript">
$(document).ready(function() {
var hide = $('.text img').data-orig-height();
if (hide === 167) {
$('.text img').css('display', 'none');
} else {
$('.text img').css('display', 'block');
}
});
</script>
图片 HTML
<figure class="tmblr-full" data-orig-height="167" data-orig-width="310">
<img src="http://40.media.tumblr.com/d190030c491be51fd47dd1f4291ae9c3/tumblr_inline_nxblnf7rF61tfshob_400.jpg" data-orig-height="167" data-orig-width="310" width="310" height="167" data-meow="true">
</figure>
hide
可以隐藏它们。但是,如果 OP 想要在某些事件上切换图像,那么这种方法就不适用了。谢谢您的建议,我已经添加了。 - Tushar