jQuery выделяет все , не имея int it

#html #jquery #css

#HTML #jquery #css

Вопрос:

У меня есть такая разметка,

     <p><strong>What is baptism and why do we get baptized?</strong></p>
<p>Being baptized in Jesus’ name shows your identification with Christ’s death, burial, and resurrection (<em>Acts 2:38; Romans 6:3-8; Colossians 2:12; 1 Peter 3:21</em>). In baptism, you as a believer are publicly testifying that when Christ died on the cross for your sins, you died to your former life of sin against God. But as Christ was raised from the dead, so you were also raised to eternal life in relationship with him. Baptism is thus a public declaration and a picture of the salvation found in Christ.</p>
<p>Jesus commanded his followers, “Go therefore and make disciples of all nations, baptizing them in the name of the Father and of the Son and of the Holy Spirit, teaching them to observe all that I have commanded you” (<em>Matthew 28:19-20</em>). The book of Acts shows that this is precisely what the apostles did after being filled with the Holy Spirit (see <em>Acts 2:41; 8:12, 38; Acts 9:18; 10:48; 16:15, 33; 18:8</em>). As Peter told a crowd, “Repent and let each of you be baptized in the name of Jesus Christ” (<em>Acts 2:38</em>).</p>
<p>In the New Testament, we consistently see that when people responded to the preaching of the gospel with faith and repentance, they were immediately baptized. Thus, conversion and baptism are very closely related. In light of these biblical truths, all Christians should seek to be baptized, and we encourage you to be baptized if you’ve put your trust in Christ.</p>
<p><strong>If I sin as a Christian, should I get baptized again?</strong></p>
<p>When we sin as Christians, we are called to repent and turn to Jesus to forgive us and change our ways. God’s word says, “If we confess our sins, he is faithful and just to forgive us our sins and to cleanse us from all unrighteousness” (<em>1 John 1:9</em>). Because of the forgiveness brought about by Jesus’ once-for-all, atoning sacrifice for sin, we do not need to be baptized every time we sin.</p>
<p><strong>Can I get baptized if I’ve been baptized before? What if I was baptized as a baby?</strong></p>
<p>Baptism is a public identification of your faith in Christ and commitment to follow him. We would only encourage you to be baptized more than once if your initial baptism was not out of a sincere belief in Jesus.</p>
<p><strong>Does baptism save?</strong></p>
<p>Several passages, on the surface, seem to teach that baptism saves (<em>Mark 16:16; Acts 2:38; Acts 22:16; 1 Peter 3:21</em>). In all these cases, however, faith in Jesus comes first. The biblical order is repentance and belief, then baptism. Scripture is abundantly clear that purification from sin is not the result of baptism (<em>Acts 15:9; 1 John 1:9</em>). However, the act of baptism is so closely related to the act of faith that they are often expressed as one act. Baptism is reserved for those who sincerely repent of their sins and place faith in the Lord Jesus. It is this faith in Christ that saves us from our sins.</p>
<p><strong>Can children be baptized?</strong></p>
<p>Reality LA believes that baptism is intended for those who believe in Christ as Lord and Savior. In the New Testament, even when whole households were baptized (<em>Acts 10:48; 16:15, 33; Acts 18:8; 1 Corinthians 1:16</em>), those who were baptized were those who heard the gospel (<em>Acts 10:44</em>) and believed (<em>Acts 16:31, 34</em>). When it comes to children, baptism is appropriate when a child displays evidence of a genuine relationship with God and a degree of understanding of what it means to trust in Christ. It is impossible to set a precise age for when a child should be baptized. The right age will vary with each child.</p>
<p><strong>Can I invite people? Should I?</strong></p>
<p>Being baptized is a celebration of who Christ is and what he’s done in your life, so we encourage you to invite friends and family members to come celebrate this event with you. Whether they are Christians or not, this is a great opportunity to show people what your faith in Jesus means to you as well as a chance for people to hear the gospel.</p>
 

Я просто хочу выбрать все <p> , в которых нет Strong

Комментарии:

1. вы пробовали что-нибудь делать сами?

Ответ №1:

Использование :not() и :has() выбор фильтров: $("p:not(:has(strong))")

 const $notHasStrong  = $("p:not(:has(strong))");
console.log($notHasStrong.length) // 1 
 <p><strong>Space</strong></p>
<p>Has no Strong</p>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> 

Или с помощью метода .not() фильтрации: $("p").not(":has(strong)")

Ответ №2:

Вы можете получить все <p> s, а затем отфильтровать те, которые не имеют <strong> :

 $('p').filter(function(){ return !$(this).find('strong').length;});
 
 var result = $('p').filter(function(){ return !$(this).find('strong').length;});
console.log('result count: '   result.length);
console.log('result content: '  result.html()); 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p><strong>P1</strong></p>
<p>P2</p>