php 中新行的 jQuery 语法是什么?

What will the jQuery syntax for new line inside php?

我试图在 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",".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);
    ?>

+ 运算符无效

我尝试了“+”和“+”
什么运营商最适合用来连接这些线路?

只需在每行末尾添加\

因此您的代码如下所示:

$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();
});  ';