<html>
<body>
<div class="hdd">
<div class="hdd_Left">
A
</div>
<div class="hdd_Center">
B
</div>
<div class="hdd_Right">
C
</div>
</div>
</body>
</html>
我想调用一个变量
<script>
$(".hdd").each(function() {
$(this).fadeTo(500,1);
$(this).getElementsByClassName("hdd_Left").animate({'margin-right': '100px'},"slow"); //doesn't work
}
</script>
$(this).getElementsByClassName("hdd_Left").animate({'margin-right': '100px'},"slow");
这条线不起作用。
谢谢
最佳答案
你真的应该写。不要混用 Vanilla JS 和 Jquery。
$(this).find(".hdd_Left").animate({'margin-right': '100px'},"slow");
关于javascript - 如何通过类内部的类名调用元素并使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45559045/