2016-05-04 61 views
2

の中に<p class="crfp-field">を非表示にして、それが内部にない場合は表示したいと考えています。あなたが私がトリックをするのを手伝ってくれることを願ってください。ここでは、コードがこれはそれを行う必要がありますクラスの要素内の要素を非表示にする

<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

次のようになります。

$('.comment-list .crfp-field').hide(); 
+0

。タグ '「 –

2

あなたはこのためにCSSを使用することができ、何のJSは必要ありません:

ol.comment-list p.crfp-field { 
    display: none; 
} 

p.crfp-field要素が内部にない場合にはol上記のルールは適用されず、要素は通常通り表示されます。

+0

そのトリックをした!ありがとうRory McCrossan :) –

+0

問題ないです、喜んで助けてください。 –

+0

乾杯!あなたは命の恩人です:) –

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 
}); 
+0

それは働いていません。プラグインのスクリプトと競合している可能性があります。 Anws、ありがとう! cssのトリックはそれをしました。 –

+0

ok no prob..fure ..! – vijayP

+0

助けてくれてありがとう:) –

関連する問題