This question already has answers here:
How to interpolate variables in strings in JavaScript, without concatenation?
                                
                                    (16个答案)
                                
                        
                2年前关闭。
            
        

我做了这个插入表行功能。我需要将p_iId,d_prijs,c_prijs,代码,artikelNL的值放入表中。我怎样才能做到这一点?

function insertTableRow ( p_iId, d_prijs, c_prijs, code, artikelNL )
{
    var $id = $('.buttonbewerken[data-id='+p_iId+']');
    var row = '<tr>';
    row += '<td class="d_prijs ruimte">5427.00</td>';
    row += '<td class="c_prijs ruimte">9999.99</td>';
    row += '<td class="code ruimte">45t45tdfgr</td>';
    row += '<td class="artikelnl ruimte">gdrge5t5</td>';
    row += '<td><button data-id= class="buttonbewerken">bewerken</button></td>';
    row += '</tr>';

    $('#result').prepend(row);
}

最佳答案

您可以简单地将它们替换为您的字符串:

关于javascript - 插入表函数如何在中获取值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47921460/

10-12 12:29