jqueryselect<;br>;标记并在其周围环绕空格
例如,我有以下标记:jqueryselect<;br>;标记并在其周围环绕空格,jquery,replace,Jquery,Replace,例如,我有以下标记: Test text<br> test2 text 测试文本 测试2文本 它的内部需要在前后都有一个空间。像这样 " <br> " “” 因此,我可以拆分整个文本,得到如下完整列表: Test text <br> test2 text 测试 文本 测试2 文本 我使用以下代码进行拆分: var words = text.split(" "); // console.log("words:" +
Test text<br>
test2 text
测试文本
测试2文本
它的内部需要在前后都有一个空间。像这样
" <br> "
“
”
因此,我可以拆分整个文本,得到如下完整列表:
Test
text
<br>
test2
text
测试
文本
测试2
文本
我使用以下代码进行拆分:
var words = text.split(" ");
// console.log("words:" + words);
for ( var i = 0, l = words.length; i<l; ++i ) {
// console.log(i +": "+words[i] );
}
var words=text.split(“”);
//console.log(“文字:”+文字);
对于(var i=0,l=words.length;i$(“#artikel”).html(函数(索引,oldhtml){
返回oldhtml.replace(/\/gi,“
”);
});
html
您能具体说明什么是“不工作”吗?您应该使用
而不是空格
// Replace all "<br>" to " <br> "
$("#artikel br").each(function(){
alert($(this).index()));
});
$("#artikel").html(function(index, oldhtml){
return oldhtml.replace(/\<br\>/gi, " <br> ");
});