HTML代码 - 有些东西无效 - 无法弄清楚什么

时间:2013-04-05 06:37:03

标签: javascript html forms syntax

我正在尝试使用on-completion函数进行倒计时插件;然而,无论出于何种原因,Dreamweaver告诉我有一个语法错误,我告诉它更改div contentcontainer的内部HTML。我一直在寻找几个小时,不能找到它的错误。我希望有人可以帮助我。任何帮助表示赞赏。

<script language="javascript" type="text/javascript">
            jQuery(document).ready(function() {
                $('#countdown_dashboard').countDown({
                    targetOffset: {
                        'day':      0,
                        'month':    0,
                        'year':     0,
                        'hour':     0,
                        'min':      5,
                        'sec':      0
                    },
                    onComplete: function() { 
                    document.getElementById('contentcontainer').innerHTML = '<div id="content">
  <div class="success_box">Application Successful!  Redirecting...</div>
    <div class="error_box"></div>
  <div class="formcontainer">
  <form id="formexample" name="example_form" action="#" method="POST">
        <label for="firstname">*First Name:</label>
        <label for="lastname">*Last Name:</label>

      <input name="firstname" id="firstname" />
      <input name="lastname" id="lastname" />

        <label for="username">*Username:</label>
        <label for="email">*Email (A Confirmation Email Will Be Sent Here) :</label>

        <input onKeyPress="makeithappen()" onKeyUp="makeithappen()" name="username" id="username" />
        <input onKeyPress="makeithappenemail()" onKeyUp="makeithappenemail()" name="email" id="email" />

        <label for="password">*Password:</label>
        <label for="password_confirm">*Confirm Password:</label>

        <input onKeyPress="makeithappenemail()" onKeyUp="makeithappenemail()" name="password" id="password" type="password" />
        <input onKeyPress="makeithappen()" onKeyUp="makeithappen()" name="password_confirm" id="password_confirm" type="password" />

    <button class="button gray" type="submit" name="submit">Submit  </button> 
    <input id="usernameused" name="usernameused" type="hidden" value=""> 
    <input id="emailused" name="emailused" type="hidden" value="">
  </form>
  </div>
</div>';
                    }

                });
            });
        </script>
<div id="contentcontainer">
</div>

1 个答案:

答案 0 :(得分:2)

您的问题是您打开了一个字符串。 Javascript不支持带有单(')或双(“)引号的多行字符串。

换句话说

var d = "hello
world "

无效,但是,您可以使用特殊字符\来“消耗”或“转义”换行符,并将其视为单行字符串。

var d = "hello \
world " 

希望这有帮助!