Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在函数调用中正确使用撇号?_Javascript_Jquery - Fatal编程技术网

Javascript 如何在函数调用中正确使用撇号?

Javascript 如何在函数调用中正确使用撇号?,javascript,jquery,Javascript,Jquery,我正在努力使“角色”正确,但我目前正在努力。 我有下面的代码 var text ="";//This variable will be initialized later. table .append( $('<tr>').append( $('<td>').html("Test:") ) .append( $('<td>').append( $('&

我正在努力使“角色”正确,但我目前正在努力。 我有下面的代码

var text ="";//This variable will be initialized later.
table
   .append(
      $('<tr>').append(
          $('<td>').html("Test:")
      )
      .append(
          $('<td>').append(
              $('<a>')
                  .attr("title", "Press to change the value").attr("href", "#")
                  .attr(
                      "onclick",
                      "AlertBox(\"Please use this dialog to update comment information.\",null,\"" + data.Id + "\",null);"
                  )
                  .text(data.Test)
          )
      )
   );
我想要以下

"AlertBox(\"Please use this dialog to update comment information.'," + text + "," + updateComment + "," +  data.Id +  "," + [data.Username,data.timestamp]
也就是说,我想调用一个接受以下参数的函数

function AlertBox(question, text, successFunction, params,additionalCommentInfoParams){}
问题是,我似乎无法正确使用逗号。您能否给我一个提示,告诉我如何打印“字符”以使其正常工作,我以前在Jquery中没有这样做过。也有可能有一个很好的工具,可以生成这个供我将来使用


提前感谢。

正如@Alex在评论中提到的,如果您希望在单击元素后弹出一个警报,那么可以通过jQuery
click
函数更容易地指定,如下所示:

var text ="";//This variable will be initialized later.
table.append($('<tr>')
    .append($('<td>')
    .html("Test:"))
    .append($('<td>')
    .append($('<a>')
    .attr("title", "Press to change the value")
    .attr("href", "#")
    .click(function(){
        AlertBox("Please use this dialog to update comment information.",null,"" + data.Id,null);
    })
    .text(data.Test))));
var text=”“//稍后将初始化此变量。
表.追加($('')
.append($('')
.html(“测试:))
.append($('')
.append($('')
.attr(“标题”,“按以更改值”)
.attr(“href”,“#”)
。单击(函数(){
AlertBox(“请使用此对话框更新注释信息。”,null,“+data.Id,null”);
})
.text(data.Test));

为什么不绑定click函数而不是将其写入onclick属性?像这样?(删除了变量,但您可以看到
/
如何与
一起工作。将
附加注释InfoParams
添加到
参数中如何,很抱歉,不得不这么说。jQuery
。单击
,而不是
。onclick
(或者更好的方法是:
.on('click',function(){});
).除此之外:正是我想建议的:-)
var text ="";//This variable will be initialized later.
table.append($('<tr>')
    .append($('<td>')
    .html("Test:"))
    .append($('<td>')
    .append($('<a>')
    .attr("title", "Press to change the value")
    .attr("href", "#")
    .click(function(){
        AlertBox("Please use this dialog to update comment information.",null,"" + data.Id,null);
    })
    .text(data.Test))));