While figuring out an answer to a question on this forum, I noticed
that .val() returns an array when used on a multiselect. and "just the
value" in all other cases. I didn't know this before, but it makes
sense. I came across this because .html() refused to insert the result
of the .val(), exiting with an error.

A thought that came to mind: Why not be more forgiving towards
arguments for .html()?
If it's not a string and not a DOM object, just convert it to a
string, since the user says he wants to insert it into the specified
element(s). If not, to insert the value of a form field read by val(),
the user has to think "Could there be any multiselects in this form?",
and if the answer is yes, he'll have to .toString() his .val() calls,
just in case. Or he'll always .toString() his .val() calls, just to be
safe. That's extra crud I'd say.

This might work for other cases as well.

As a programmer, I'd rather have 'Object' appear in my html than an
error from jquery.js. We all know this behavior from alert (those
things we used to debug before Firebug).

Reply via email to