Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
126
rated 0 times [  132] [ 6]  / answers: 1 / hits: 24547  / 11 Years ago, tue, september 3, 2013, 12:00:00

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);
});
});


Any suggestion would be great.


More From » jquery

 Answers
31

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);
});
});

[#75930] Monday, September 2, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
orlando

Total Points: 413
Total Questions: 92
Total Answers: 96

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
;