如果井号显示在网页上的任何位置,则显示某些内容

Show certain content if a pound sign shows anywhere on the web page

本文关键字:显示 位置 任何 网页 如果井      更新时间:2023-09-26

我们创建了以下内容,以便在我们的网站上查找国旗,并在我们的网站上显示某些国家/地区的国旗时显示消息。

我想调整它以在下面显示消息,除非页面上的任何地方显示井号 (£)。我该怎么做?非常感谢

<p id="checkout_notification_text" style="display:none;margin-top:-7px;"><b>As you are viewing prices in a currency other than GBP, prices shown will be converted into GBP by your card processor. This card processor <i>may</i> add a currency conversion fee of up to 2.5%.</b></p>
 <script type="text/javascript">
    var flg =readCookie("currencyflag");
    if (!flg) {
             $("dl.CurrencyList").children().eq(0).find("img").each(function(){
                flg =$(this).attr("src"); 
             });
     }
    if(flg) {
        var flgImgArray = flg.split("/");
        var flgImg = flgImgArray[flgImgArray.length-1]; 
        if(flgImg != 'gb.gif'){
           $('#checkout_notification_text').show();
        }else{
           $('#checkout_notification_text').hide();
        }
    }
</script>  

我现在使用的代码:

<p id="checkout_notification_text" style="display:none;margin-top:-7px;"><b>As you are viewing prices in a currency other than GBP, prices shown will be converted into GBP by your card processor. This card processor <i>may</i> add a currency conversion fee of up to 2.5%.</b></p>
 <script type="text/javascript"> 
if ($("body:contains('£')").length) {
 $('#checkout_notification_text').hide();
} else {
//it is not found
}
 </script>  

我认为您仍然想进行标记搜索,但如果找到£以始终隐藏标志

使用 jquery

http://jsfiddle.net/a4U5A/3/

if ($("body:contains('£')").length) {
     $('#checkout_notification_text').hide();
} else {
    //it is not found
}