我想在<p class="crfp-field">
内隐藏<ol class="comment-list">
并显示它是否在其中。希望你能帮助我做到这一点。这是代码的样子
<ol class="comment-list">
<li class="comment">
<div id="comment-n">
<p>This is a comment</p>
</div>
<ul class="children">
<li class="comment">
<div id="comment-n">
<p>This is a reply to a comment. Star rating is visible here. I don’t want to display it when I am replying to a comment.</p>
</div>
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title">Write a Reply or Comment <small><a class="btn" rel="nofollow" id="cancel-comment-reply-link" href="" style="">Cancel Reply</a></small></h3>
<form action="http://../wp-comments-post.php" method="post" id="commentform" class="comment-form">
<p class="comment-notes">Your email address will not be published.</p>
<p class="comment-form-author">Name<input id="author" name="author" type="text"></p>
<p class="comment-form-email">Email<input id="email" name="email" type="text"></p>
<p class="comment-form-url">Website<input id="url" name="url" type="text"></p>
<!-- CRFP Fields: Start -->
<p class="crfp-field">
<!-- CRFP Stuff -->
</p>
<!-- CRFP Fields: End -->
<p class="comment-form-comment">Comment<textarea id="comment" name="comment"></textarea></p>
<input id="submit-new" value="Post Comment" type="submit">
</form>
</div>
</li><!-- #comment-## -->
</ul><!-- .children -->
</li><!-- #comment-## -->
</ol>
答案 0 :(得分:2)
你可以使用CSS,不需要JS:
ol.comment-list p.crfp-field {
display: none;
}
如果p.crfp-field
元素不在ol
内,则不会应用上述规则,该元素将正常显示。
答案 1 :(得分:0)
这应该这样做:
$('.comment-list .crfp-field').hide();
答案 2 :(得分:0)
您可以通过以下方式实现:
$(document).ready(function(){
$("p.crfp-field").show(); //show all p tag with class crfp-field
$("ol.comment-list p.crfp-field").hide(); //hide the needed ones
});