Reputation: 21
I'd like to hide the <p class="crfp-field">
inside <ol class="comment-list">
and show it if it's not inside it. Hope you could help me do the trick. Here's what the code looks like
<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>
Upvotes: 2
Views: 48
Reputation: 11502
You can do achieve it via following way:
$(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
});
Upvotes: 0
Reputation: 337580
You can use CSS for this, no JS required:
ol.comment-list p.crfp-field {
display: none;
}
If the p.crfp-field
element is not inside the ol
then the rule above will not be applied and the element will be displayed as normal.
Upvotes: 2