小编Ana*_*son的帖子

为什么"\n"即使被告知不要创建新行?

即使在被告知没有复制时,我也会遇到"\n"创建一条线的问题.修复可能是一些简单的事情,我只是因为某种原因没有看到.我很感激对此问题的任何意见或指导.

(请只给我Javascript答案,因为我对jquery或其他方法不感兴趣)

       <script type="text/javascript">

        if (pullDownResponseE == "")
        {
        }
        else {
        var pullDownValuesE = document.getElementById("taskOne");
        var pullDownResponseE = pullDownValuesE.options[pullDownValuesE.selectedIndex].value;
        stuffToCopy = stuffToCopy + "\n" + pullDownResponseE;
        }


        if (pullDownResponseF == "")
        {
        }
        else{
        var pullDownValuesF = document.getElementById("taskTwo");
        var pullDownResponseF = pullDownValuesF.options[pullDownValuesF.selectedIndex].value;
        stuffToCopy = stuffToCopy + "\n" + pullDownResponseF;
        }

        </script>
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,如果我的下拉值等于""并且此部分大部分工作,则pullDownResponseF和pullDownReponseE不会执行任何操作,它不执行新行"\n"部分的任何其他代码EXCEPT.

任何人都可以解释这里出了什么问题吗?

编辑:拥有更多代码可能会有所帮助.我只会包含必要部分,因为它太长了.

        <script type="text/javascript">

        function copyNotesTemplate()
        { 

        var stuffToCopy = document.getElementById('myForm').value;
        if(stuffToCopy.length > 1)
        {
        var stuffToCopy = "PT meets criteria" + "\n" + document.getElementById('myForm').value;
        }
        if(document.getElementById('noPtCriteria').checked) …
Run Code Online (Sandbox Code Playgroud)

javascript newline

6
推荐指数
1
解决办法
129
查看次数

标签 统计

javascript ×1

newline ×1