Jquery: Syntax error, unrecognized expression :nth-child()
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've used someone else's answer to get this. Jquery: $("input:checkbox:not(:checked)").each(function() { var columnName = $(this).attr('name'); $('td:nth-child(' + columnName + '),th:nth-child(' + columnName + ')').hide(); }); $("input:checkbox").click(function() { var columnName = $(this).attr('name'); $('td:nth-child(' + columnName + '),th:nth-child(' + columnName + ')').toggle(); }); HTML: <input type="checkbox" name="1" checked="checked"/> It works when I put values in the :nth-child(1) but not when I include the variable. Am I doing it