问题描述
我正在尝试在jQuery中找到运算符以在PHP中的jq代码时在下一行中编写代码
这是我的工作代码:-
<?PHP
$addoldgoldrow = '
$(document).on("click",".add_btns",function(e) {
e.preventDefault();
var markups = "<tr class=\'rowaccs\'><td><input type=\'text\' class=\'sl_no\' name=\'sl_no[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'oweight inputBox input_table1\' name=\'oweight[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'ostone_weight inputBox input_table1\' name=\'ostone_weight[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'ovd inputBox input_table1\' name=\'ovd[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'onet_weight inputBox input_table1\' name=\'onet_weight[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'orate inputBox input_table1\' name=\'orate[]\' value=\'' . $Metal_rate . '\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'oamount inputBox input_table1 table1_end row_end\' name=\'oamount[]\' style=\'width: 100%\' readonly></td><td><span class=\'rowcloSEOldgold\'><i class=\'fa fa-times\' style=\'color: #C11429;\' aria-hidden=\'true\'></i></span></td</tr>";
$("table#old_gold tbody").append(markups);
indexassigneroldpurchase();
});
';
$this->registerJs($addoldgoldrow,View::POS_READY);
?>
并且我想这样做
<?PHP
$addoldgoldrow = '
$(document).on("click",function(e) {
e.preventDefault();
var markups = "<tr class=\'rowaccs\'>
<td><input type=\'text\' class=\'sl_no\' name=\'sl_no[]\' style=\'width: 100%\'></td>
<td><input type=\'text\' class=\'oweight inputBox input_table1\' name=\'oweight[]\' style=\'width: 100%\'></td>
<td><input type=\'text\' class=\'ostone_weight inputBox input_table1\' name=\'ostone_weight[]\' style=\'width: 100%\'></td>
<td><input type=\'text\' class=\'ovd inputBox input_table1\' name=\'ovd[]\' style=\'width: 100%\'></td>
<td><input type=\'text\' class=\'onet_weight inputBox input_table1\' name=\'onet_weight[]\' style=\'width: 100%\'></td>
<td><input type=\'text\' class=\'orate inputBox input_table1\' name=\'orate[]\' value=\'' . $Metal_rate . '\' style=\'width: 100%\'></td>
<td><input type=\'text\' class=\'oamount inputBox input_table1 table1_end row_end\' name=\'oamount[]\' style=\'width: 100%\' readonly></td>
td><span class=\'rowcloSEOldgold\'><i class=\'fa fa-times\' style=\'color: #C11429;\' aria-hidden=\'true\'></i></span></td</tr>";
$("table#old_gold tbody").append(markups);
indexassigneroldpurchase();
});
';
$this->registerJs($addoldgoldrow,View::POS_READY);
?>
+运算符无效
我尝试了“ +”和“ +”
理想情况下,什么运营商用于连接这些线路?
解决方法
只需在每行末尾添加\
所以您的代码如下:
$addoldgoldrow = '
$(document).on("click",".add_btns",function(e) {
e.preventDefault();
var markups = "<tr class=\'rowaccs\'> \
<td><input type=\'text\' class=\'sl_no\' name=\'sl_no[]\' style=\'width: 100%\'></td> \
<td><input type=\'text\' class=\'oweight inputbox input_table1\' name=\'oweight[]\' style=\'width: 100%\'></td> \
<td><input type=\'text\' class=\'ostone_weight inputbox input_table1\' name=\'ostone_weight[]\' style=\'width: 100%\'></td> \
<td><input type=\'text\' class=\'ovd inputbox input_table1\' name=\'ovd[]\' style=\'width: 100%\'></td> \
<td><input type=\'text\' class=\'onet_weight inputbox input_table1\' name=\'onet_weight[]\' style=\'width: 100%\'></td> \
<td><input type=\'text\' class=\'orate inputbox input_table1\' name=\'orate[]\' value=\'' . $metal_rate . '\' style=\'width: 100%\'></td> \
<td><input type=\'text\' class=\'oamount inputbox input_table1 table1_end row_end\' name=\'oamount[]\' style=\'width: 100%\' readonly></td> \
td><span class=\'rowcloseoldgold\'><i class=\'fa fa-times\' style=\'color: #C11429;\' aria-hidden=\'true\'></i></span></td</tr>";
$("table#old_gold tbody").append(markups);
indexassigneroldpurchase();
}); ';