简体   繁体   English

我在我的js代码中缺少的东西我正在丢失)错误

[英]What i am missing in my js code i am getting missing ) error

What am I missing in my code? 我的代码中缺少什么? I am getting following error in the developer console. 我在开发人员控制台中遇到以下错误。

Uncaught SyntaxError: missing ) after argument list

Full code here: 完整代码在这里:

    .html('<textarea id="textarea" rows="1" class="form-control chatboxtextarea" data-autosize-on="true" style="overflow: hidden; word-wrap: break-word; height: 30px;" 
onkeypress="javascript:return updateLastTypedTime();" onkeyup="javascript:return refreshTypingStatus(' + chatboxtitle + "','" + toid + "');\" 
onkeydown=\"javascript:return checkChatBoxInputKey(event,this,'" + chatboxtitle + "','" + toid + "','" + img + '\');">
</textarea>');

I think i am missing something this line: 我认为我在此行中缺少了一些东西:

onkeypress="javascript:return updateLastTypedTime();" onkeyup="javascript:return refreshTypingStatus(' + chatboxtitle + "','" + toid + "');\"

but where I really can not fined :/ 但是我真的不能罚款:/

.html(
    '<textarea id="textarea" rows="1" class="form-control chatboxtextarea" data-autosize-on="true" style="overflow: hidden; word-wrap: break-word; height: 30px;"
    onkeypress="javascript:return updateLastTypedTime();"
    onkeyup="javascript:return refreshTypingStatus(' + chatboxtitle + "','" + toid + "');\" 
    onkeydown=\"javascript:return checkChatBoxInputKey(event,this,'" + chatboxtitle + "','" + toid + "','" + img + '\');">

Those quotes are a mess. 这些引述是一团糟。 The problem lies right here: 问题就在这里:

'...refreshTypingStatus(' + chatboxtitle + "','" + toid + "')
^                       ^                  ^
|                       |                  |
|                       Your closing       Your opening quote for
Your opening quote      quote for the      another string literal.
for the string          string literal     These are suddenly
literal                                    double quotes. Bad.
                                           Don't mix up quotes.

So when the HTML is inserted by the html() function, your refreshTypingStatus() function becomes this: 因此,当通过html()函数插入html() ,您的refreshTypingStatus()函数将变为:

refreshTypingStatus(Nice title','My very own toid')

As you can see, the title doesn't start with quotes. 如您所见,标题不是以引号开头。 You'll need to simply insert the quote: 您只需要插入引号即可:

'...refreshTypingStatus(\'' + chatboxtitle + "','" + toid + "')..."

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM