簡體   English   中英

強大的wrapp鏈接與replace()

[英]Wrapp link in strong with replace()

我想在div中圍繞我的鏈接制作一個強大的標簽。 這些鏈接動態顯示。

我試着這樣做:

$('#alertWrapp').each(function() {
  $(this).html($(this).text()
    .replace(/#[a-z0-1A-Z]+/g, '<span style="color: #ed6567;">$&</span>')
    .replace('http://', '<strong>$&</strong>')
  );
});

但我不能繼續正則表達式,它太復雜了......所以有可能建立一個正在尋找http:// protocole到空間的正則表達式? 因為這是一個設置鏈接結束的空間......

謝謝

你為什么不給錨定風格呢? 檢查這個小提琴

a {
font-weight: bolder;
}

要么

如果您希望以粗體包裝的網址文本嘗試以下操作或檢查此小提琴

var text = data.replace(/https?:\/\/[^ ]+/g, '<strong>$&</strong>')

要替換http:// [任何直到空格]或https:// [任何]嘗試此操作

$('#alertWrapp').each(function() {
    $(this).html(
        $(this).text()
        .replace(/#[a-z0-1A-Z]+/g, '<span style="color: #ed6567;">$&</span>')
        .replace(/https?:\/\/[^ ]+/g, '<strong>$&</strong>')
    );
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM