Forgot to demo my custom selector:
$("#myForm :userInput")
Selects all children of #myForm that either have a type of "text",
"password", "radio", "checkbox" or "file", are <select> elements, or are
<textarea> elements.
On 3/14/07, Aaron Heimlich <[EMAIL PROTECTED]> wrote:
$("input:not(:submit):not(:reset):not(:button):not(:image):not(:hidden),select,textarea")
grabs all <input>'s that are NOT of type "submit", "reset", "button",
"image" or "hidden", all <select>'s and all <textarea>'s.
You could also do
$("input:text,input:checkbox,input:password,input:radio,input:file,select,textarea")
but you'd be selecting the same group on <input>'s five times instead once
like in the first example.
Both of those are pretty verbose, which is very unjQuery-like. But, one of
the really cool things about jQuery selectors is that you can add your own
custom selectors really easily, like so:
jQuery.expr[":"].userInput = "/text|password|radio|checkbox|file/i.test(
a.type) || /select|textarea/i.test(a.nodeName)";
Selectors are nothing more than a piece of JavaScript code that gets
eval'd by the selection engine. The variable "a" is the DOM node that jQuery
is currently examining.
Here's a list of all of the official selectors:
http://dev.jquery.com/browser/trunk/jquery/src/selector/selector.js
And some more custom selectors (though some of these have been merged into
the jQuery core)
http://www.softwareunity.com/sandbox/JQueryMoreSelectors/
On 3/13/07, Rick Faircloth <[EMAIL PROTECTED]> wrote:
>
> Hi, all...
>
> How can this code be modified to accept others types
> of input besides "text"? I need to be able to include input
> from selects, radio, and checkboxes...
>
> > // select all inputs of type text
> > $("input:text").each(function(){
> > Params[$(this).attr("name")] = $(this).val();
> > }); // closes input:text function
>
> Thanks,
>
> Rick
>
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com
--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/