【发布时间】:2015-11-11 04:05:04
【问题描述】:
我正在构建一个以 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>
【问题讨论】:
标签: javascript jquery html css tumblr