我试图将div附加到append中,但我总是得到SyntaxError: missing ) after argument list
我的div看起来像
<div class='col-md-6'>
<div class='form-group'>
<?= $this->Form->control('user_id', ['options' => $users,'class'=>'form-control']);?>
</div>
<div class='form-group'>
<?= $this->Form->control('phone_number',['class'=>'form-control']); ?>
</div>
</div>
我尝试了如下所示的追加
$('#cform').append("<div class='col-md-6'><div class='form-group'><?= $this->Form->control('user_id', ['options' => $users,'class'=>'form-control']);?></div><div class='form-group'><?= $this->Form->control('phone_number',['class'=>'form-control']); ?></div></div>");
我在这里没有任何语法错误,如何解决呢?
答案 0 :(得分:0)
您可以使用反勾`
$('#cform').append(`<div class='col-md-6'><div class='form-group'><?= $this->Form->control('user_id', ['options' => $users,'class'=>'form-control']);?></div><div class='form-group'><?= $this->Form->control('phone_number',['class'=>'form-control']); ?></div></div>`);
IE中可能不支持反勾号,因此可以在空格前使用“ \”
示例:
<div class="form-group">\
<?= $this->Form->control('user_id', ['options' => $users,'class'=>'form-control']);?>\
</div>\
<div class="form-group">\
<?= $this->Form->control('phone_number',['class'=>'form-control']); ?>\
</div>\