我知道代码可以工作,因为它在 JSfiddle 中进行了测试,但是将其放入此 HTML 中会导致错误,除非 JQuery Mobile 它干扰?
所以我已经剥离了 CSS 以进行测试,但无论我拿走什么,它都会在向列表中添加新项目时导致错误。
这是工作版本: DEMO
<title>Checklist</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
    </script>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.1.0/jquery.mobile-1.1.0.min.js">
    </script>
<script>
$('#add').on('click', function (e) {
var $this = $(this);
var $firstRow=$this.closest('table').find('tr:first');
var $newRow = $firstRow.clone();
var input = $newRow.find(':input').remove();
input.prop('checked', false);
$newRow.empty().append(input).append(' '+$('#textinput4').val());
$newRow.insertAfter($firstRow);
});
</script>
</head>
<body>
<div data-role="page" id="check">
        <div data-theme="a" data-role="header">
            <h3>
                Checklist
            </h3>
            <a data-role="button" data-transition="fade" href="#about" class="ui-btn-left">
                Back
            </a>
        </div>
        <div data-role="content" style="padding: 15px">
            <div data-role="collapsible-set">
            <form name="emailform" enctype="multipart/form-data" action="form-to-email.php" method="get">
              <div data-role="fieldcontain">
                 <label for='name'>Festival name: </label><br>
        <input type="text" name="name">
                    <h3>
                        Before you go
                    </h3>
                        <fieldset data-role="controlgroup" data-type="vertical">
                            <legend>
                            </legend>
                            <input name="checkbox62" id="checkbox62" type="checkbox" />
                            <label for="checkbox62">
                                Charge all batteries. Phones, cameras etc
                            </label>
                            <input name="checkbox63" id="checkbox63" type="checkbox" />
                            <label for="checkbox63">
                                Save your friends numbers
                            </label>
                            <input name="checkbox64" id="checkbox64" type="checkbox" />
                            <label for="checkbox64">
                                Check out festival site rules!
                            </label>
                            <tr><td><input name="checkbox65" id="checkbox65" type="checkbox" /></td>
                            <td><label for="checkbox65">Get directions for where you are going</label></td></tr>
                        </fieldset>
                     <h3>My items</h3>
                    <table id="myTable">
<tr>
    <td>
    <label for="checkbox65">
        <input name="checkbox65" class="checkbox65" type="checkbox" />
        Get directions for where you are going
    </label>
    </td>
</tr> 
<tr>
    <td>
        <fieldset data-role="controlgroup">
            <label for="textinput4">
                Add new item
                <input name="new_item" id="textinput4" placeholder="" value="" type="text" />
            </label>
        </fieldset>
        <button id="add">Add</button>
    </td>
</tr>
</table>
  </form>