alert($('#Content_tab form .form-group:nth-last-child(2)').html());
nth-last-child(n)
上的这个和更多选择在 chrome 中不起作用!!
他们如何在所有其他浏览器中正常工作,例如在 IE8、Mozilla 中。
请查看我的 Site和 source code
you can find the code near line no. 502
最佳答案
使用这个
$('#Content_tab form .form-group').eq(-2).html()
作为一名 javascript 开发人员,我一点也不喜欢那个选择器。使用那种选择器再次成为我的规则。这将是非常不高效的。您可以在构建标记时为该元素提供一些类,或者这样更好。
$("#Content_tab").find(".form-group").eq(-2).html()
关于javascript - 选择器 'nth-last-child(n)' 在 chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21003819/