我在 HTML 中的 php 代码
$i = 1;
echo "<input type='text' class='uborder help-80percent' maxlength='3' onkeypress='return isNumberKey(event)'' id='quantity_".$i."' onchange='updatetotalWeight(this.value, quantity_".$i.", current_quantity_".$i.", weight_".$i." )' />";
我想做我的:
updatetotalWeight(this.value, "quantity_1", "current_quanitity_1", "weight_1");
你知道如何让这个东西变成字符串吗?
最佳答案
您可以在双引号字符串中使用双引号,方法是用反斜杠转义它们 \"
:
echo "<input type='text' class='uborder help-80percent' maxlength='3' onkeypress='return isNumberKey(event)' id='quantity_".$i."' onchange='updatetotalWeight(this.value, \"quantity_".$i."\", \"current_quantity_".$i."\", \"weight_".$i."\" )' />";
关于javascript - ECHO 双单引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30280770/