Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在每个圆括号前添加带有新id的跨度标记_Javascript_Php_Html_Tags_Prepend - Fatal编程技术网

Javascript 在每个圆括号前添加带有新id的跨度标记

Javascript 在每个圆括号前添加带有新id的跨度标记,javascript,php,html,tags,prepend,Javascript,Php,Html,Tags,Prepend,我有一些文本有一些类似于韵文的引用,我需要在每个圆括号前自动添加一个带有新id的span标记(当访问页面时) 输入: <p>some text (Jn 1:2), more text sentences (Gn 5-12, 23 ref) and more etc.</p> 您可以混合使用jQuery和: 设i=0; $('p').html((\ux,oldHtml)=> 替换(/\([^]+\)/g,匹配=>`${match}`) ); 一些文本(Jn 1:2),

我有一些文本有一些类似于韵文的引用,我需要在每个圆括号前自动添加一个带有新id的span标记(当访问页面时)

输入:

<p>some text (Jn 1:2), more text sentences (Gn 5-12, 23 ref) and more etc.</p>

您可以混合使用jQuery和:

设i=0;
$('p').html((\ux,oldHtml)=>
替换(/\([^]+\)/g,匹配=>`${match}`)
);

一些文本(Jn 1:2),更多文本句子(Gn 5-12,23 ref)等等。

<p>some text <span id="1">(Jn 1:2)</span>, more text sdfkljgdf <span id="2">(Gn 5-12, 23)</span> and more etc.</p>
var myString_before = str.split("(")[count];
//alert (myString_before);

//get all text before )
var myString_after = myString_before.split(")")[0];
alert(" ref: " + myString_after);

if (x != true) {
    $('span').each(function (k) {
        var replace_str = $(this).html().replace(/\(/g, '<div 
        style="display: inline" id= "' + pos + '">(</div>');
        $(this).html(replace_str);
    })
}
x = document.getElementsByTagName('div')[count].hasAttribute("style");