通过使用Css或Jquery隐藏跨度的第一个单词 [英] Hide First Word of Span by using Css or Jquery

查看:87
本文介绍了通过使用Css或Jquery隐藏跨度的第一个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用css隐藏第一个字(ILS)。我有一个没有class的div,里面有div。我只想隐藏这个字(ILS) span ...请指导我在哪里我错了



在网站上显示的文字如下:



这是我的div:

 < div class =purhstdtls-delvry-timesec> 
< h5>测试样本< / h5>
< div class =purchase-price>< / div>
< div>某些文字在这里< / div>
< div>
< span> ILS 0.10 /מכירה< / span>
< / div>
< / div>

Css:

  .purhstdtls-delvry-timesec> div:nth-​​child(4)> span:第一个字{
display:none;
}


解决方案

或者已经在后端发送正确的东西,但是:
您可以直接替换内容。



 < head>< script src =https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js>< /脚本><脚本> $(文件)。就绪(函数(){$( '跨度')文本($( '跨度')文本()代替( 'ILS', ''));。。}) ;< /脚本>< /头> < div class =purhstdtls-delvry-timesec> < h5>测试样本< / h5> < div class =purchase-price>< / div> < div>一些文字在这里< / div> < DIV> < span> ILS 0.10 /מכירה< / span> < / DIV> < / div>  



这是一个肮脏的解决方案,但它会工作。

I want to hide first word(ILS) from the span by using css..I have a div which have no class and inside that div there is a span...I just want to hide this word(ILS) from the span...Please guide me where i am wrong

Text displayed like this on the site:

Here is my div:

<div class="purhstdtls-delvry-timesec">
  <h5>Test Sample</h5>
  <div class="purchase-price"></div>
  <div>Some Text Here</div>
  <div>
        <span>ILS 0.10 / מכירה</span>
  </div>
</div> 

Css :

.purhstdtls-delvry-timesec>div:nth-child(4)>span:first-word{
   display:none;
}

解决方案

Preferably you add an id to the span or already send the right thing in the backend but: You can just replace the content.

<head><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script>$(document).ready(
function(){
$('span').text($('span').text().replace('ILS',''));
});
</script>
</head>


    <div class="purhstdtls-delvry-timesec">
      <h5>Test Sample</h5>
      <div class="purchase-price"></div>
      <div>Some Text Here</div>
      <div>
            <span>ILS 0.10 / מכירה</span>
      </div>
    </div>

It's a dirty solution but it'll work.

这篇关于通过使用Css或Jquery隐藏跨度的第一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆