我的代码中都有这种类型的代码
<td><font color="#3586DF"><b><span>1</span></b></font></td>
<td><font color="#3586DF"><b><a href="#"><font color="#3586DF">2</font></a></b></font></td>
我想用强替换 b 并删除字体标记
结果应为
<td><strong><span>1</span></strong></td>
<td><strong><a href="#">2</a></strong></td>
我如何使用jquery,javascript或Css
答案 0 :(得分:1)
可以使用jQuery replaceWith()
< div class="row clients-testimonials" data-aos="fade-up">
<div class="testimonials">
<div class="testimonials__slide">
<p>Qui ipsam temporibus quisquam vel. Maiores eos cumque distinctio nam accusantium ipsum.
Laudantium quia consequatur molestias delectus culpa facere hic dolores aperiam. Accusantium quos qui praesentium corpori.
Excepturi nam cupiditate culpa doloremque deleniti repellat.</p>
<img src="images/avatars/user-01.jpg" alt="Author image" class="testimonials__avatar">
<div class="testimonials__info">
<span class="testimonials__name">Tim Cook</span>
<span class="testimonials__pos">CEO, Apple</span>
</div>
</div>
<div class="testimonials__slide">
<p>Excepturi nam cupiditate culpa doloremque deleniti repellat. Veniam quos repellat voluptas animi adipisci.
Nisi eaque consequatur. Quasi voluptas eius distinctio. Atque eos maxime. Qui ipsam temporibus quisquam vel.</p>
<img src="images/avatars/user-05.jpg" alt="Author image" class="testimonials__avatar">
<div class="testimonials__info">
<span class="testimonials__name">Sundar Pichai</span>
<span class="testimonials__pos">CEO, Google</span>
</div>
</div>
<div class="testimonials__slide">
<p>Repellat dignissimos libero. Qui sed at corrupti expedita voluptas odit. Nihil ea quia nesciunt. Ducimus aut sed ipsam.
Autem eaque officia cum exercitationem sunt voluptatum accusamus. Quasi voluptas eius distinctio.</p>
<img src="images/avatars/user-02.jpg" alt="Author image" class="testimonials__avatar">
<div class="testimonials__info">
<span class="testimonials__name">Satya Nadella</span>
<span class="testimonials__pos">CEO, Microsoft</span>
</div>
</div>
</div><!-- end testimonials -->
</div> <!-- end col-full -->
</div> <!-- end client-testimonials -->
</section> <!-- end s-clients --<div class="col-full">
&#13;
$('font').replaceWith(function() {
return $(this).contents()
})
$('b').replaceWith(function() {
return $('<strong>').append($(this).html())
})
console.log($('table').html())
&#13;
strong,
strong a {
color: red
}
&#13;
答案 1 :(得分:0)
您可以使用循环在表格中找到b标签,并将其替换为。
$('#testtable').find('tr > td > font > b').each(function() {
$(this).replaceWith($('<strong>' + $(this).html() + '</strong>'));
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id='testtable'><tr>
<td><font color="#3586DF"><b><span>1</span></b></font></td>
<td><font color="#3586DF"><b><a href="#"><font color="#3586DF">2</font></a></b></font></td>
</tr></table>
&#13;