如图,我想点击第n个li则第n个p和第n个th隐藏,怎么没效果?

<script> $("ul li:nth-child(n)").click(function(){ $(".id p:nth-child(n)").hide(); $("table tr th:nth-child(n)").hide(); }); </script>










繁星淼淼
浏览 98回答 1
1回答

www说

$('ul&nbsp;li').click(function(){&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;index&nbsp;=&nbsp;$(this).index()&nbsp;&nbsp;&nbsp;&nbsp;$('.id&nbsp;p').eq(index).hide()&nbsp;&nbsp;&nbsp;&nbsp;$('table&nbsp;tr&nbsp;th').eq(index).hide()})div:nth-child(n) &nbsp; &nbsp;代表div里面的所有子元素div:nth-child(2n) &nbsp; &nbsp;代表div里面的双数元素 0,2,4,6,8,......div:nth-child(2n+1) &nbsp; 代表div里面的单数元素 1,3,5,7,9,......
打开App,查看更多内容
随时随地看视频慕课网APP