【问题标题】:nth-child(4n) in jquery for old browsers用于旧浏览器的 jquery 中的 nth-child(4n)
【发布时间】:2013-10-17 11:44:43
【问题描述】:

此代码在所有浏览器中都可以正常工作,但在 Internet Explorer 和旧版浏览器中无法正常工作。旧浏览器和 Internet Explorer 也可以使用 jquery 来实现吗?

.post {position:relative;float:left;width:207px;height:300px;margin-right:24px}
.post:nth-child(4n) {margin-right:0px !important;}

【问题讨论】:

  • 他在他的问题中指定了 jquery...
  • 因为他想用jQuery在不支持选择器的浏览器中实现样式?
  • 这些“帖子”是否从服务器输出到页面?如果是这样,直接在预期元素上输出一个类并使用该类进行样式设置而不是使用 jQuery 来完成它会更容易和更轻松。

标签: jquery css wordpress html css-selectors


【解决方案1】:

你可以。在 jQuery 中,尝试

$(".post:nth-child(4n)").css('margin-right', '0px !important');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-30
    • 1970-01-01
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多