0

我想让对话框中的消息显示类似“选择你想踢/禁止(玩家名)的方式”

我当前的代码看起来像这样

$(document).on("click", ".btn-ban", function(e) {
    var username = ($(this).attr('id'));
    bootbox.dialog({
       message: "Choose how you want to ban "+$username,
       title: "Ban Player",
       backdrop:false,
       buttons: {

感觉代码的其余部分并不重要

我已经尝试从 ancor 标记中获取 id,该标记由 php 定义为玩家名称。

但是自从我在消息中添加了“+$uername”之后,对话框就不会显示了。

有任何想法吗?

4

2 回答 2

0

Its username not $username like,

message: "Choose how you want to ban "+username,

Full Code

$(document).on("click", ".btn-ban", function(e) {
    var username = this.id; // you can use it simply without using attr()
    bootbox.dialog({
       message: "Choose how you want to ban "+username,
       title: "Ban Player",
       backdrop:false,
       buttons: {
于 2013-11-07T08:43:16.430 回答
0

如果你想连接phpvarialbe 那么这样使用,

$(document).on("click", ".btn-ban", function(e) {
var username = this.id; // you can use it simply without using attr()
bootbox.dialog({
   message: "Choose how you want to ban "+ <?php echo $username; ?>,
   title: "Ban Player",
   backdrop:false,
   buttons: {
于 2013-11-07T11:26:21.953 回答