javascript - 在 JS 确认()方法中使用 PHP 变量

标签 javascript php variables confirm

这是一个简单的问题,我有一个变量(一个字符串),它根据上一页中的用户操作而变化,它可以是“package”,“content”等。

由于修改可能会产生后果,我想通过使用确认方法来确保用户了解他的操作,如果这是一个包或"is",则该方法会说“您确定要删除此包吗”你...此内容”等。

在我的 JS 中我这样做了:

var sCategorieType = $(this).closest('tr').attr('name');

我想这样做:

var bConfirm = confirm("Are you sure you want to delete this'.sCategorieType.'? ");

这不起作用,我想知道原因并有替代方案。

最佳答案

JavaScript 中的串联与 PHP 中的串联不同。在 JavaScript 中,您可以使用 + 符号连接字符串。

尝试:

var bConfirm = confirm("Are you sure you want to delete this " + sCategorieType + "? ");

关于javascript - 在 JS 确认()方法中使用 PHP 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36469792/

相关文章:

javascript - 在 Webpack 4 中,我们可以使用 import() token 动态生成页面 block ,以便我们可以将 react 组件转换为可 react 加载的组件吗?

php - 使用php在桶谷歌云存储中创建文件夹

php - ob_implicit_flush(), flush(), ob_flush() - 不在远程服务器上工作

页面刷新后Javascript存储变量

javascript - 原型(prototype)中相邻函数的问题

c# - 异步 Controller 通过 jQuery 阻止 ASP.NET MVC 中的请求

javascript - Nodejs http.createServer 回调

php - 将自定义路径设置为 php.ini(不在 Apache 中)

Java Integer.MIN_VALUE 的负数然后比较产生两个负数

python - 如何评估字符串作为变量名