javascript - ECHO 双单引号

标签 javascript php html

我在 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." )' />";

enter image description here

我想做我的:

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/

相关文章:

javascript - 如何制作循环来确定将在 JS 上选取哪个变量

javascript - 基于 Vue JS 中的选择下拉菜单自动填充输入

php - 交响乐2 : Doctrine constraints in forms

html - 位置 h1,边框位于图片中心

javascript - HTML/CSS 根据文本长度改变 anchor

javascript - 如何添加标签 <html :submit> dynamically?

php - 我的站点 htaccess 需要短 URL

php - 在 PHP 中进行身份验证的最佳方式

javascript - fullpage.js 如何将固定菜单附加到第二部分

javascript - 在 Firefox 中输入选择焦点的外观