错误跟踪[行:42] Le contenu des éléments doit inclure un balisage ou des caractères au format correct [重复]

Posted

技术标签:

【中文标题】错误跟踪[行:42] Le contenu des éléments doit inclure un balisage ou des caractères au format correct [重复]【英文标题】:Error Traced[line: 42] Le contenu des éléments doit inclure un balisage ou des caractères au format correct [duplicate] 【发布时间】:2013-09-06 10:56:12 【问题描述】:

我在 html 中有一个运行良好的 jquery 代码:

<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Dialog - Modal form</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <style>
    body  font-size: 62.5%; 
    label, input  display:block; 
    input.text  margin-bottom:12px; width:95%; padding: .4em; 
    fieldset  padding:0; border:0; margin-top:25px; 
    h1  font-size: 1.2em; margin: .6em 0; 
    div#users-contain  width: 350px; margin: 20px 0; 
    div#users-contain table  margin: 1em 0; border-collapse: collapse; width: 100%; 
    div#users-contain table td, div#users-contain table th  border: 1px solid #eee; padding: .6em 10px; text-align: left; 
    .ui-dialog .ui-state-error  padding: .3em; 
    .validateTips  border: 1px solid transparent; padding: 0.3em; 
  </style>
  <script>
  $(function() 
    var name = $( "#name" ),
      email = $( "#email" ),
      password = $( "#password" ),
      allFields = $( [] ).add( name ).add( email ).add( password ),
      tips = $( ".validateTips" );

    function updateTips( t ) 
      tips
        .text( t )
        .addClass( "ui-state-highlight" );
      setTimeout(function() 
        tips.removeClass( "ui-state-highlight", 1500 );
      , 500 );
    

    function checkLength( o, n, min, max ) 
      if ( o.val().length > max || o.val().length < min ) 
        o.addClass( "ui-state-error" );
        updateTips( "Length of " + n + " must be between " +
          min + " and " + max + "." );
        return false;
       else 
        return true;
      
    

    function checkRegexp( o, regexp, n ) 
      if ( !( regexp.test( o.val() ) ) ) 
        o.addClass( "ui-state-error" );
        updateTips( n );
        return false;
       else 
        return true;
      
    

    $( "#dialog-form" ).dialog(
      autoOpen: false,
      height: 300,
      width: 350,
      modal: true,
      buttons: 
        "Create an account": function() 
          var bValid = true;
          allFields.removeClass( "ui-state-error" );

          bValid = bValid && checkLength( name, "username", 3, 16 );
          bValid = bValid && checkLength( email, "email", 6, 80 );
          bValid = bValid && checkLength( password, "password", 5, 16 );

          bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
          // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
          bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
          bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

          if ( bValid ) 
            $( "#users tbody" ).append( "<tr>" +
              "<td>" + name.val() + "</td>" +
              "<td>" + email.val() + "</td>" +
              "<td>" + password.val() + "</td>" +
            "</tr>" );
            $( this ).dialog( "close" );
          
        ,
        Cancel: function() 
          $( this ).dialog( "close" );
        
      ,
      close: function() 
        allFields.val( "" ).removeClass( "ui-state-error" );
      
    );

    $( "#create-user" )
      .button()
      .click(function() 
        $( "#dialog-form" ).dialog( "open" );
      );
  );
  </script>
</head>
<body>

<div id="dialog-form" title="Create new user">
  <p class="validateTips">All form fields are required.</p>

  <form>
  <fieldset>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
    <label for="email">Email</label>
    <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
    <label for="password">Password</label>
    <input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
  </fieldset>
  </form>
</div>


<div id="users-contain" class="ui-widget">
  <h1>Existing Users:</h1>
  <table id="users" class="ui-widget ui-widget-content">
    <thead>
      <tr class="ui-widget-header ">
        <th>Name</th>
        <th>Email</th>
        <th>Password</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>
        <td>john.doe@example.com</td>
        <td>johndoe1</td>
      </tr>
    </tbody>
  </table>
</div>
<button id="create-user">Create new user</button>


</body>
</html> 

但是当我将此代码移动到 JSF 时,代码不起作用:

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
  <meta charset="utf-8" />
  <title>jQuery UI Dialog - Modal form</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <style>
    body  font-size: 62.5%; 
    label, input  display:block; 
    input.text  margin-bottom:12px; width:95%; padding: .4em; 
    fieldset  padding:0; border:0; margin-top:25px; 
    h1  font-size: 1.2em; margin: .6em 0; 
    div#users-contain  width: 350px; margin: 20px 0; 
    div#users-contain table  margin: 1em 0; border-collapse: collapse; width: 100%; 
    div#users-contain table td, div#users-contain table th  border: 1px solid #eee; padding: .6em 10px; text-align: left; 
    .ui-dialog .ui-state-error  padding: .3em; 
    .validateTips  border: 1px solid transparent; padding: 0.3em; 
  </style>
  <script>
  $(function() 
    var name = $( "#name" ),
      email = $( "#email" ),
      password = $( "#password" ),
      allFields = $( [] ).add( name ).add( email ).add( password ),
      tips = $( ".validateTips" );

    function updateTips( t ) 
      tips
        .text( t )
        .addClass( "ui-state-highlight" );
      setTimeout(function() 
        tips.removeClass( "ui-state-highlight", 1500 );
      , 500 );
    

    function checkLength( o, n, min, max ) 
      if ( o.val().length > max || o.val().length < min ) 
        o.addClass( "ui-state-error" );
        updateTips( "Length of " + n + " must be between " +
          min + " and " + max + "." );
        return false;
       else 
        return true;
      
    

    function checkRegexp( o, regexp, n ) 
      if ( !( regexp.test( o.val() ) ) ) 
        o.addClass( "ui-state-error" );
        updateTips( n );
        return false;
       else 
        return true;
      
    

    $( "#dialog-form" ).dialog(
      autoOpen: false,
      height: 300,
      width: 350,
      modal: true,
      buttons: 
        "Create an account": function() 
          var bValid = true;
          allFields.removeClass( "ui-state-error" );

          bValid = bValid && checkLength( name, "username", 3, 16 );
          bValid = bValid && checkLength( email, "email", 6, 80 );
          bValid = bValid && checkLength( password, "password", 5, 16 );

          bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
          // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
          bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
          bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

          if ( bValid ) 
            $( "#users tbody" ).append( "<tr>" +
              "<td>" + name.val() + "</td>" +
              "<td>" + email.val() + "</td>" +
              "<td>" + password.val() + "</td>" +
            "</tr>" );
            $( this ).dialog( "close" );
          
        ,
        Cancel: function() 
          $( this ).dialog( "close" );
        
      ,
      close: function() 
        allFields.val( "" ).removeClass( "ui-state-error" );
      
    );

    $( "#create-user" )
      .button()
      .click(function() 
        $( "#dialog-form" ).dialog( "open" );
      );
  );
  </script>
    </h:head>

    <h:body>

<div id="dialog-form" title="Create new user">
  <p class="validateTips">All form fields are required.</p>

  <form>
  <fieldset>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
    <label for="email">Email</label>
    <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
    <label for="password">Password</label>
    <input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
  </fieldset>
  </form>
</div>


<div id="users-contain" class="ui-widget">
  <h1>Existing Users:</h1>
  <table id="users" class="ui-widget ui-widget-content">
    <thead>
      <tr class="ui-widget-header ">
        <th>Name</th>
        <th>Email</th>
        <th>Password</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>
        <td>john.doe@example.com</td>
        <td>johndoe1</td>
      </tr>
    </tbody>
  </table>
</div>
<button id="create-user">Create new user</button>


    </h:body>
</html>

我有这个错误 Error Traced[line: 42] Le contenu des éléments doit inclure un balisage ou des caractères au format correct

:[line: 42] > if (o.val().length > max || o.val().length

HTML:

XHTML:

【问题讨论】:

JSF 假定 XML,对吗?尝试将所有&lt; 替换为&amp;#60;,并将所有&amp; 替换为&amp;#38;,看看是否有帮助。 请修复您的开发环境以发出英文错误消息。否则,当您将确切的错误消息复制粘贴到搜索框甚至 Google 中时,您将永远无法在 Stack Overflow 上找到正确的答案。 我添加到我的代码&lt;![CDATA[ ]]&gt; 现在我没有错误,但我有相同的屏幕,我为 XHTML 显示的屏幕在单击创建新用户时没有任何效果。 它现在可以工作了,我添加了 &lt;![CDATA[ ]]&gt; 代替 //&lt;![CDATA[ my js code here //]]&gt; 我也遇到了同样的问题。问题是我的文档顶部有一个像这样的 XML 声明。我还必须删除我的 html 标记中的 xmlns="w3.org/1999/xhtml 属性。这个问题来自哪里?当您使用 Netbeans 创建 html 文件时,您需要选择文件扩展名类型。Netbeans 8 有 2 种不同的所以叫做“创建Html文件”。第一个是经典的html 5文件。第二个似乎是Xml文件……即使你点击“创建一个html文件”。 【参考方案1】:

由于您将在 JSF 中使用 XHTML,因此您必须将 &amp;amp; 替换为 &amp;amp; ,将 &amp;lt; 替换为 &amp;lt;&amp;gt; 替换为 &amp;gt;。 所以我对你的代码进行了修改,替换了相应的函数。

function checkLength( o, n, min, max ) 
          if ( o.val().length &gt; max || o.val().length &lt; min ) 
            o.addClass( "ui-state-error" );
            updateTips( "Length of " + n + " must be between " +
              min + " and " + max + "." );
            return false;
           else 
            return true;
          
        

 "Create an account": function() 
          var bValid = true;
          allFields.removeClass( "ui-state-error" );

          bValid = bValid &amp;&amp; checkLength( name, "username", 3, 16 );
          bValid = bValid &amp;&amp; checkLength( email, "email", 6, 80 );
          bValid = bValid &amp;&amp; checkLength( password, "password", 5, 16 );

          bValid = bValid &amp;&amp; checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
          // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
          bValid = bValid &amp;&amp; checkRegexp( email, /^((([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
          bValid = bValid &amp;&amp; checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

这是完整的修改代码:

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
  <meta charset="utf-8" />
  <title>jQuery UI Dialog - Modal form</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <style>
    body  font-size: 62.5%; 
    label, input  display:block; 
    input.text  margin-bottom:12px; width:95%; padding: .4em; 
    fieldset  padding:0; border:0; margin-top:25px; 
    h1  font-size: 1.2em; margin: .6em 0; 
    div#users-contain  width: 350px; margin: 20px 0; 
    div#users-contain table  margin: 1em 0; border-collapse: collapse; width: 100%; 
    div#users-contain table td, div#users-contain table th  border: 1px solid #eee; padding: .6em 10px; text-align: left; 
    .ui-dialog .ui-state-error  padding: .3em; 
    .validateTips  border: 1px solid transparent; padding: 0.3em; 
  </style>
  <script>
  $(function() 
    var name = $( "#name" ),
      email = $( "#email" ),
      password = $( "#password" ),
      allFields = $( [] ).add( name ).add( email ).add( password ),
      tips = $( ".validateTips" );

    function updateTips( t ) 
      tips
        .text( t )
        .addClass( "ui-state-highlight" );
      setTimeout(function() 
        tips.removeClass( "ui-state-highlight", 1500 );
      , 500 );
    

    function checkLength( o, n, min, max ) 
      if ( o.val().length &gt; max || o.val().length &lt; min ) 
        o.addClass( "ui-state-error" );
        updateTips( "Length of " + n + " must be between " +
          min + " and " + max + "." );
        return false;
       else 
        return true;
      
    

    function checkRegexp( o, regexp, n ) 
      if ( !( regexp.test( o.val() ) ) ) 
        o.addClass( "ui-state-error" );
        updateTips( n );
        return false;
       else 
        return true;
      
    

    $( "#dialog-form" ).dialog(
      autoOpen: false,
      height: 300,
      width: 350,
      modal: true,
      buttons: 
        "Create an account": function() 
          var bValid = true;
          allFields.removeClass( "ui-state-error" );

          bValid = bValid &amp;&amp; checkLength( name, "username", 3, 16 );
          bValid = bValid &amp;&amp; checkLength( email, "email", 6, 80 );
          bValid = bValid &amp;&amp; checkLength( password, "password", 5, 16 );

          bValid = bValid &amp;&amp; checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
          // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
          bValid = bValid &amp;&amp; checkRegexp( email, /^((([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&amp;'\*\+\-\/=\?\^_`\|~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
          bValid = bValid &amp;&amp; checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

          if ( bValid ) 
            $( "#users tbody" ).append( "<tr>" +
              "<td>" + name.val() + "</td>" +
              "<td>" + email.val() + "</td>" +
              "<td>" + password.val() + "</td>" +
            "</tr>" );
            $( this ).dialog( "close" );
          
        ,
        Cancel: function() 
          $( this ).dialog( "close" );
        
      ,
      close: function() 
        allFields.val( "" ).removeClass( "ui-state-error" );
      
    );

    $( "#create-user" )
      .button()
      .click(function() 
        $( "#dialog-form" ).dialog( "open" );
      );
  );
  </script>
    </h:head>

    <h:body>

<div id="dialog-form" title="Create new user">
  <p class="validateTips">All form fields are required.</p>

  <form>
  <fieldset>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
    <label for="email">Email</label>
    <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
    <label for="password">Password</label>
    <input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />
  </fieldset>
  </form>
</div>


<div id="users-contain" class="ui-widget">
  <h1>Existing Users:</h1>
  <table id="users" class="ui-widget ui-widget-content">
    <thead>
      <tr class="ui-widget-header ">
        <th>Name</th>
        <th>Email</th>
        <th>Password</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>
        <td>john.doe@example.com</td>
        <td>johndoe1</td>
      </tr>
    </tbody>
  </table>
</div>
<button id="create-user">Create new user</button>


    </h:body>
</html>

编辑 另一种选择是使用外部 javascript。 将您的 javascript 保存在单独的文件中,例如:script.js 并使用以下标签访问它:

 <script type="text/javascript" src="script.js"/>

这种技术现在在我的电脑上运行良好。

【讨论】:

我使用了你的代码,但我仍然有同样的问题,请参阅我的更新我在 HTML 中拥有的内容和我在 XHTML 中拥有的内容。 xhtml 中的“创建新用户”按钮没有显示模态表单。 我在发布此主题之前已经尝试过此方法,不同之处在于单击我的按钮时我没有错误但无效,并且第一页中显示的表单显示错误。跨度>

以上是关于错误跟踪[行:42] Le contenu des éléments doit inclure un balisage ou des caractères au format correct [重复]的主要内容,如果未能解决你的问题,请参考以下文章

编译代码时出现 LNK2019 错误

此行已经属于另一个表

四方定理(洛谷 1586)

从堆栈跟踪中查找共享库中的源代码行

Le Chapitre X

ejabberd:跟踪名册和存在导致错误