admin管理员组

文章数量:1289634

I am getting the error missing ) after argument list in my Firebug console.

I can't understand why. The problem is with the text that is passed in as an argument to the before() method. I am pretty sure it's something to do with the quotation marks. I have tried doing \" and \' instead of ' but neither was successful, they gave different errors.

As long as I can add the HTML that is within the before() method I don't mind how I solve this.

$(document).ready( 
        function () {
        $("#add").click( 
             function () {
             $("#add").before("<s:text name='queries[0].property' class='small-text' size='28'/><span class='small-text'> = </span>");

        });
    });

I am getting the error missing ) after argument list in my Firebug console.

I can't understand why. The problem is with the text that is passed in as an argument to the before() method. I am pretty sure it's something to do with the quotation marks. I have tried doing \" and \' instead of ' but neither was successful, they gave different errors.

As long as I can add the HTML that is within the before() method I don't mind how I solve this.

$(document).ready( 
        function () {
        $("#add").click( 
             function () {
             $("#add").before("<s:text name='queries[0].property' class='small-text' size='28'/><span class='small-text'> = </span>");

        });
    });
Share Improve this question asked Jul 30, 2011 at 10:20 AnkurAnkur 51.1k114 gold badges248 silver badges316 bronze badges 5
  • 2 That code seems to be working on it's own: jsfiddle/shanethehat/aNgSM – shanethehat Commented Jul 30, 2011 at 10:26
  • I would bet on a Firebug bug. – Déjà vu Commented Jul 30, 2011 at 10:30
  • 1 Thanks, yes it does. I am trying to figure it out. I have a feeling it's to do with the Stripes s: prefix. – Ankur Commented Jul 30, 2011 at 10:44
  • @ring0 actually the content never shows up, so it's causing an issue in my app as well. – Ankur Commented Jul 30, 2011 at 10:44
  • Looks like the JS is ok, so it must be something to do with Stripes. – Ankur Commented Jul 30, 2011 at 10:47
Add a ment  | 

3 Answers 3

Reset to default 4

There is nothing wrong with the code that you show, so you probably have got some unprintable character in the string that keeps it from working.

Try to copy the string and past it back, or if that doesn't fix it, retype the string.

Looks like you are using jQuery. I'd bet the missing ')' is something to do with your document.ready, looks unbalanced.

Try doing it like this:

$(function(){
        $("#add").click(function(){
             $("#add").before("<s:text name='queries[0].property' class='small-text' size='28'/><span class='small-text'> = </span>");
        });
});

It's the same as document.ready, just a shortcut but I use it all the time. Think this should be ok.

Hope it helps

EDIT:

Oops I missed that string :)

I'd also try out JK's answer, that looks good to me.

I think you have to escape some characters, because the HTML parser interprets a </ sequence as the end of a script. So try to use <\/ instead:

$(document).ready(
    function () {
    $("#add").click( 
         function () {
             $("#add").before("<s:text name='queries[0].property' class='small-text' size='28'/><span class='small-text'> = <\/span>");
        });
    });

本文标签: Javascript error quotmissing ) after argument listquotStack Overflow