根据< br />拆分字符串使用jquery标记 [英] Split the string based on <br/> tag using jquery
本文介绍了根据< br />拆分字符串使用jquery标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用jquery拆分包含< br />
标记的字符串。我尝试了以下代码,但它在控制台中出错。我不确定如何根据< br />
标签拆分字符串以下是我试过的代码
How can i split the string containing <br/>
tag using jquery. I tried the following code but it get error in console. I am not sure how to split the string based on <br/>
tag Here is the code what i tried
jQuery(document).ready(function($)
{
var lines = jQuery('this is for testing <br/> How are you<br/>').split('<br/>');
jQuery.each(lines, function() {
alert(this);
});
});
任何建议都会很棒。
推荐答案
你想拆分一个香草字符串,不要简单地将它传递给 $()
;
You want to split a vanilla string, don't pass it to $()
rather simply;
jQuery(document).ready(function($)
{
var lines = 'this is for testing <br/> How are you<br/>'.split('<br/>');
jQuery.each(lines, function() {
alert(this);
});
});
这篇关于根据< br />拆分字符串使用jquery标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文