我想让这段代码工作,但.css函数正在返回undefined
$(".split-section-headings .ssh-cell")
.html("This container has padding-top = " + $(this).css("paddingTop") );
谢谢!
答案 0 :(得分:2)
如果没有类似于$(this)
的内容或在事件处理程序中,则无法使用.each()
:
$(".split-section-headings .ssh-cell").each(function() {
$(this).html("This container has padding-top = " + $(this).css("padding"));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="split-section-headings">
<div class="ssh-cell"></div>
</div>