I'd total agree with what Michael said. Infact HTML coding guidelines and
W3C Standards say that HTML quotes should be double "
Also as a PHP developer I tend to use single quotes ' for programming, but
that's because in PHP it doesn't use the parse engine looking for varibles,
but thats a different topic ;) So I tend to also use single quotes in
Javascript, it's just easier that way.

/James

On 10/2/07, Michael Geary <[EMAIL PROTECTED]> wrote:
>
>
> > From: James Dempster
> >
> > Much nicer to split the lines making it more readable.
> >
> > $(this).parent().append([
> >     "<p>",
> >         "<input type='text' class='"+inputClass+"'",
> >         "<button onclick='$(this).parent().remove();return
> false;'>x</button>",
> >     "</p>"
> > ].join(""));
>
> Also, once you're using .join, you don't have to use + inside it; you can
> use comma for all your string concatenation. And there's a missing /> in
> the
> input tag, so let's fix that:
>
> $(this).parent().append([
>      "<p>",
>          "<input type='text' class='", inputClass, "' />",
>          "<button onclick='$(this).parent().remove();return
> false;'>x</button>",
>      "</p>"
> ].join(""));
>
> Finally, this is purely stylistic, but I like to put the begin tags and
> end
> tags on separate lines to make it easier to make sure they are matched up,
> and also (really getting into personal preference here) I like to swap
> around the " and ' quote marks, using " as the HTML quote and ' as the
> JavaScript quote:
>
> $(this).parent().append([
>      '<p>',
>          '<input type="text" class="', inputClass, '" />',
>          '<button onclick="$(this).parent().remove();return false;">',
>              'x',
>          '</button>',
>      '</p>'
> ].join(''));
>
> I do the quotes this way because seems a lot more common to use " in HTML
> code, and because I type a lot more JavaScript quotes than HTML quotes, so
> using ' for the JavaScript quotes makes it a tiny bit easier to type. :-)
>
> -Mike
>
>
> >
>

Reply via email to