user281117 Asked:2020-01-17 03:14:33 +0000 UTC2020-01-17 03:14:33 +0000 UTC 2020-01-17 03:14:33 +0000 UTC 我无法选择最近的元素并单击打开它,这是什么原因? 772 当您单击链接时,应该会出现最近的隐藏窗口 $(document).ready(function(){ $('.catalog_section__a').click(function(){ $(this).closest('.catalog_section_cell').find('.catalog_section_popup').show(); }); }); javascript 3 个回答 Voted Kirill 2020-01-17T03:39:18Z2020-01-17T03:39:18Z $(document).ready(function() { $('.catalog_section__a').click(function() { $(this).parent().parent().find($('.catalog_section_popup')).show(); }); }); .catalog_section_popup { display: none; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="catalog_section_cell"> <div class="catalog_section_popup">catalog_section_popup</div> <div> <div class="catalog_section__a">catalog_section__a</div> </div> </div> user281117 2020-01-17T04:47:41Z2020-01-17T04:47:41Z $(document).ready(function() { $('.catalog_section__a').click(function() { $(this).closest('.catalog_section_cell').find('.catalog_section_popup').show(); }); }); Best Answer Denis 2020-01-17T05:34:19Z2020-01-17T05:34:19Z 根据 jQuery,一切都是正确的,除了执行 e.preventDefault() 也不错。问题只会出现在 HTML 标记中,因为您在可点击链接中有一个空白,最好将图像或文本放在那里。而且,当然,您需要查看链接的 CSS 样式,是否为其设置了尺寸
根据 jQuery,一切都是正确的,除了执行 e.preventDefault() 也不错。问题只会出现在 HTML 标记中,因为您在可点击链接中有一个空白,最好将图像或文本放在那里。而且,当然,您需要查看链接的 CSS 样式,是否为其设置了尺寸