【发布时间】:2017-03-01 09:34:53
【问题描述】:
这是我的 jquery 代码。我需要 javascript 代码来选择第 n 个孩子。是否可以使用 javascript 选择第 n 个孩子
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".gl-testim-text p:nth-child(2)").click(function(){
$(".gl-testim-text p:nth-child(3)").show();
});
});
</script>
【问题讨论】:
-
document.querySelectorAll('p:nth-child(n)') -
@nikhil OP 意味着没有 jQuery
-
我认为
$(this).next()应该可以帮到你! -
@Rajesh - 感谢您的澄清!我误解了。
标签: javascript jquery