jquery-selectorswildcardjquery-attributes

JQuery Wildcard for using atttributes in selectors


I've research this topic extensibly and I'm asking as a last resort before assuming that there is no wildcard for what I want to do.

I need to pull up all the text input elements from the document and add it to an array. However, I only want to add the input elements that have an id.

I know you can use the \S* wildcard when using an id selector such as $(#\S*), however I can't use this because I need to filter the results by text type only as well, so I searching by attribute.

I currently have this:

values_inputs = $("input[type='text'][id^='a']");

This works how I want it to but it brings back only the text input elements that start with an 'a'. I want to get all the text input elements with an 'id' of anything. I can't use:

values_inputs = $("input[type='text'][id^='']"); //or
values_inputs = $("input[type='text'][id^='*']"); //or
values_inputs = $("input[type='text'][id^='\\S*']"); //or
values_inputs = $("input[type='text'][id^=\\S*]"); 
//I either get no values returned  or a syntax error for these

I guess I'm just looking for the equivalent of * in SQL for JQuery attribute selectors. Is there no such thing, or am I just approaching this problem the wrong way?


Solution

  • Actually, it's quite simple:

    var values_inputs = $("input[type=text][id]");