小编Rei*_*ahm的帖子

根据Javascript中的换行符解析子串中的textarea

我有一个需要解析的文本区域.需要拔出每个新线路并且需要对其执行操作.操作完成后,需要在下一行运行操作.这就是我现在所拥有的.我知道indexOf搜索不起作用,因为它逐个字符地搜索.

function  convertLines()
{
trueinput = document.getElementById(8).value;  //get users input
length = trueinput.length; //getting the length of the user input
newinput=trueinput;  //I know this looks silly but I'm using all of this later
userinput=newinput;
multiplelines=false; //this is a check to see if I should use the if statement later
    for (var i = 0; i < length; i++) //loop threw each char in user input
        {
            teste=newinput.charAt(i); //gets the char at position i
            if (teste.indexOf("<br />") != -1) //checks if …
Run Code Online (Sandbox Code Playgroud)

javascript

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×1