Raphael Milani
Raphael Milani

Reputation: 151

Regex JQuery Find Elements By Type

I´ve been trying to find elements by type for example radio,text and etc

I tried this code by Jquery:

$j("input[type^='text']").each(function(){
            alert($j(this).attr("id"));
});

The code above works properly, but I would like to find like this:

$j("input[type='text'|'radio']").each(function(){
            alert($j(this).attr("id"));
});

Is it possible? I am stucked!

Upvotes: 0

Views: 150

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

You need to use Multiple Selector:

$j("input[type='text'],input[type='radio']").each(function(){
         alert($j(this).attr("id"));
});

You can also use :text and :radio selectors:

$j("input:text,input:radio").each(function(){
         alert($j(this).attr("id"));
});

Upvotes: 1

Related Questions