我有3個圖像塊,其上有文本。以下是3箇中的一個的樣子。獲取每個元素獲取高度並將其應用爲邊緣頂部
<div class="lp">
<h2 class="align-vert">
This is my title
</h2>
</div>
我想拿到冠軍height();
jQuery中,並將其應用到aligh-v
。我嘗試了下面的jQuery代碼,但它不起作用。
jQuery.each(jQuery('.js-vert'), function() {
jQuery(this).css({
"margin-top": '"' + jQuery('.js-vert').height() + '"'
});
});
什麼是'.js文件 - 翻轉?它似乎不包含在您的DOM中。 –