如何解决jQuery目标html5标记属性
| 我正在尝试使用jQuery来简单地添加.alt
类来替换主section
中的article
块,如下所示:
html5:
<section id=\"content\" role=\"main\">
<h1>Main Title</h1>
<article id=\"post-1\" class=\"post-1 post type-post\">
.. article content ..
</article>
<article id=\"post-2\" class=\"post-2 post type-post\">
.. article content ..
</article>
<article id=\"post-3\" class=\"post-3 post type-post\">
.. article content ..
</article>
</section>
jQuery的:
$(\'#content article:nth-child(odd)\').addClass(\'alt\');
我在想什么吗...?这肯定行得通吗?!
解决方法
上面的代码确实有效,但我的jQuery文件中的其他内容却抛出了问题。请参阅上面的评论。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。