为了账号安全,请及时绑定邮箱和手机立即绑定

在图像,类或ID上应用href

在图像,类或ID上应用href

萧十郎 2022-09-16 22:02:19
我是一名设计师。我需要将 中包含的相同 href 放在 中,或 中,或 包含在 中。class="kt-testimonial-title"id="slick-slide10"class="kt-testimonial-item-wrap kt-testimonial-item-0"class="kt-testimonial-image"使用jquery或javascript可以吗?部分:<div class="kt-blocks-testimonial-carousel-item kb-slide-item slick-slide slick-current slick-active" style="width: 337px;" role="tabpanel" id="slick-slide10" aria-describedby="slick-slide-control10" data-slick-index="0" aria-hidden="false">  <div class="kt-testimonial-item-wrap kt-testimonial-item-0" style="border-color:rgba(238, 238, 238, 1);padding-top:40px;padding-right:40px;padding-bottom:40px;padding-left:40px;max-width:500px"><div class="kt-testimonial-text-wrap">  <div class="kt-testimonial-media-wrap">    <div class="kt-testimonial-media-inner-wrap" style="border-radius:px;border-width:0px 0px 0px 0px;padding:2px 2px 2px 2px">      <div class="kadence-testimonial-image-intrisic" style="padding-bottom:100%">        <div class="kt-testimonial-image" style="background-image:url(&quot;http://homeagent.devup.site/wp-content/uploads/2020/05/pegn.png&quot;);background-size:Contain"></div>      </div>    </div>  </div>  <div class="kt-testimonial-title-wrap">    <h6 class="kt-testimonial-title">      <a href="https://revistapegn.globo.com/Tecnologia/noticia/2020/04/coronavirus-de-ti-gestao-de-ponto-o-mercado-das-empresas-que-ajudam-no-home-office.html" target="_blank" aria-label=" (opens in a new tab)" rel="noreferrer noopener"        class="ek-link" tabindex="0">De TI a gestão de ponto: o<br> mercado das empresas que<br> ajudam no home office</a>    </h6>  </div>  <div class="kt-testimonial-content-wrap">    <div class="kt-testimonial-content"></div>  </div></div>  </div></div>源:http://homeagent.devup.site/sobre/
查看完整描述

2 回答

?
幕布斯7119047

TA贡献1794条经验 获得超8个赞

试试吧:


// add common alias jquery 

$ = jQuery;


const anchors = $('.kt-blocks-testimonial-carousel-item a.ek-link');


$.each(anchors, function (i, e) {

  let anchor = $(e);

  let text = anchor.text();

  let textContainer = anchor.parent();

  let newAnchor = anchor.clone().empty();

  let carouselItem = anchor.parents('.kt-blocks-testimonial-carousel-item');


  carouselItem.wrap(newAnchor);

  textContainer.text(text);

});

这是一个不漂亮的代码,但在javascript控制台上 http://homeagent.devup.site/sobre/


查看完整回答
反对 回复 2022-09-16
?
德玛西亚99

TA贡献1770条经验 获得超3个赞

这将工作:


<div class="kt-blocks-testimonial-carousel-item kb-slide-item slick-slide slick-current slick-active" style="width: 337px;" role="tabpanel" id="slick-slide10" aria-describedby="slick-slide-control10" data-slick-index="0" aria-hidden="false"><div class="kt-testimonial-item-wrap kt-testimonial-item-0" style="border-color:rgba(238, 238, 238, 1);padding-top:40px;padding-right:40px;padding-bottom:40px;padding-left:40px;max-width:500px"><div class="kt-testimonial-text-wrap"><div class="kt-testimonial-media-wrap"><div class="kt-testimonial-media-inner-wrap" style="border-radius:px;border-width:0px 0px 0px 0px;padding:2px 2px 2px 2px"><div class="kadence-testimonial-image-intrisic" style="padding-bottom:100%"><div class="kt-testimonial-image" style="background-image:url(&quot;http://homeagent.devup.site/wp-content/uploads/2020/05/pegn.png&quot;);background-size:Contain"></div></div></div></div><div class="kt-testimonial-title-wrap"><h6 class="kt-testimonial-title"><a href="https://revistapegn.globo.com/Tecnologia/noticia/2020/04/coronavirus-de-ti-gestao-de-ponto-o-mercado-das-empresas-que-ajudam-no-home-office.html" target="_blank" aria-label=" (opens in a new tab)" rel="noreferrer noopener" class="ek-link" tabindex="0">De TI a gestão de ponto: o<br> mercado das empresas que<br> ajudam no home office</a></h6></div><div class="kt-testimonial-content-wrap"><div class="kt-testimonial-content"></div></div></div></div></div>

    

<script>

        var slidesArr = document.querySelectorAll('.slick-slide');

        slidesArr.forEach(function(slide){

            var a = document.createElement('a');

            a.href = slide.querySelector('.kt-testimonial-title a').getAttribute('href');

            a.appendChild(slide.querySelector('.kt-testimonial-item-wrap'));

            slide.appendChild(a);

        });

</script>


查看完整回答
反对 回复 2022-09-16
  • 2 回答
  • 0 关注
  • 81 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信