在#content文本之前插入span标记

我想知道如何使用jquery在#符号内容之前插入span标记。 对不起这个问题。 我还是jquery的新手。

 $(document).ready(function() { var text = $(".name a").text(); //alert(text); if (text.contains("#")) { alert("yes"); } else { alert("no"); } });   

输出应该是这样的

  

试试这个样本:

 $(document).ready(function() { var textElement = $(".name > a"), text = textElement.text(); textElement.html(text.replace(/#[0-9]+/g, '$&')); }); 
   
  var text=$(".name a").text(); text.replace(/(\#[\w]*)/g,"$1"); 

我不确定它是否会起作用请检查出来。

根据@Shrikanth Buds的回答:

首先将类添加到要处理的所有此类链接。 我在本例中使用了类’hashcontainers’。 然后,尝试下面的代码: