未捕获的ReferenceError:onclick函数未定义变量

时间:2015-03-14 00:57:37

标签: javascript html function referenceerror

我是编码的新手,但我很难找到为什么我在Chrome中的“添加新任务”按钮上没有任何反应时获得referenceError。

这是我的功能,它创建视图,我试图有一个onclick功能,带来一个带有字段的灯箱。

“添加新任务”按钮位于代码段的底部

感谢帮助!

    <script type="text/javascript">
      function action_form(id) {
          $("#dialog_form").remove();
          $("#tasks-form").append('
        <div id="dialog_form"></div>');
          $("#dialog_form").attr("title", (id !== undefined ? "Edit task" : "Create new task"));
          $("#dialog_form").html('
        <div>' + '
    </script>

    <div class="blocks">
      <h1>Tasks for your MultiScraper</h1>
      <div class="text-block">
        <input type="button" value=" + Add new task" class="btn btn-blue" onclick="action_form();" id="tasks_add_button" style="float: right;margin: 10px 30px 10px 0;" />
        <input type="button" value="Products grabbed" class="btn btn-grey" onclick="" id="tasks_grabbed_product_button" style="float: left;margin: 10px 30px 10px 30px;" />
        <div class="clear"></div>

        <div id="tasks-form" class="ms_form" style="padding: 10px;width: 1240px;padding-bottom: 0;">
          <div id="form-content">

            <table class="list" id="parser_instruction_table">
              <thead>
                <tr id="instruction_table_header">
                  <td colspan="10">You have not yet made ​​any task for your MSPRO. Please, create the first one</td>
                </tr>
              </thead>

1 个答案:

答案 0 :(得分:0)

function action_form(id) {
    $("#dialog_form").remove();
    $("#tasks-form").append('
                           <div id="dialog_form"></div>');
    $("#dialog_form").attr("title", (id !== undefined ? "Edit task" : "Create new task"));
    $("#dialog_form").html('
                          <div>' + '

在写字符串时留下换行符,就像在

中一样
$("#tasks-form").append('
                       <div id="dialog_form"></div>');

$("#dialog_form").html('
                      <div>' + '

会导致错误。

$("#tasks-form").append('<div id="dialog_form"></div>');

或者,如果 打破新行

$("#tasks-form").append('' +
                       '<div id="dialog_form"></div>');

此外,

还有问题
$("#dialog_form").html('<div>' + '

看起来您忘记关闭括号和功能的括号

相关问题