How can i split the string containing
tag using jquery. I tried the following code but it get error in console. I am not sure how to split the strin
Lots of duplicate answers here. This one is different. If you can guarantee the spelling of the
tag, the other answers are fine. But if you have no control over the HTML, the line break tag could come in different formats:
...etc.
major browsers can all handle all of these, but only the first will be handled by the suggested .split("
operation. A more robust option is to use a regular expression to match the tag:
")
jQuery(document).ready(function($)
{
var brExp = /
/i;
var lines = ("this is for testing
How are you
").split(brExp);
});
I've written the expression to be case-insensitive, allow any number of spaces after '